use Cwd;
use DBI;
use Benchmark;
use Time::HiRes qw(usleep ualarm gettimeofday tv_interval);
use POSIX;
$count=10000;
@nums = (0 .. 9999);
print "wj Test of execute selects of 100 items\n";
$loop_time=new Benchmark;
for ($i=1 ; $i <= $count ; $i++)
{
my ($key_value)=$random[$i];
my ($query)= "select * from bench1 where id<$key_value and id>($key_value+100)";
print "$query\n" if ($opt_debug);
$t0 = [gettimeofday];
$sth = $dbh->prepare($query);
while ($sth->fetchrow_arrayref) { };
$nums[$i-1] = floor(tv_interval($t0, [gettimeofday])*1000000 + 0.5);
$sth->finish;
};
$end_time=new Benchmark;
print "Time for prepared_select ($count): " .
timestr(timediff($end_time, $loop_time),"all") . "\n";
#wj
@nums = sort{$a<=>$b}(@nums);
open (MYFILE, '>tmp');
for ($i= 0; $i< $count; $i++) {
$percent = $i/$count;
$cdf = join "",$nums[$i],"\t",$percent;
if ($nums[$i] != $nums[$i+1] || $i == count-1) {
print MYFILE "$cdf\n";
}
}
close (MYFILE);
Tuesday, January 19, 2010
perl Generate CDF for Benchmark Tests
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment