Benchmark.t: ignore sys CPU time
authorDavid Mitchell <davem@iabyn.com>
Wed, 15 Jun 2011 15:17:01 +0000 (16:17 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 15 Jun 2011 15:23:10 +0000 (16:23 +0100)
Currently we work out the CPU burned by a loop by summing user and sys
CPU. On the grounds that the burning we're interested in should have all
been carried out with user CPU and that therefore any sys CPU is a red
herring, ignore sys CPU for the infamous test 15.

Yes, this is clutching at straws. Still, diagnostics output may show
in future whether I was right!

lib/Benchmark.t

index fde9ada..004092e 100644 (file)
@@ -63,8 +63,9 @@ isnt ($baz, 0, "benchmarked code was run");
 my $in_threesecs = $threesecs->iters;
 print "# in_threesecs=$in_threesecs iterations\n";
 ok ($in_threesecs > 0, "iters returned positive iterations");
-my $cpu3 = $threesecs->[1] + $threesecs->[2]; # user + sys
-cmp_ok($cpu3, '>=', 3.0, "3s cpu3 is at least 3s");
+my $cpu3 = $threesecs->[1]; # user
+my $sys3 = $threesecs->[2]; # sys
+cmp_ok($cpu3+$sys3, '>=', 3.0, "3s cpu3 is at least 3s");
 my $in_threesecs_adj = $in_threesecs;
 $in_threesecs_adj *= (3/$cpu3); # adjust because may not have run for exactly 3s
 print "# in_threesecs_adj=$in_threesecs_adj adjusted iterations\n";
@@ -78,8 +79,9 @@ isnt ($baz, 0, "benchmarked code was run");
 my $in_onesec = $onesec->iters;
 print "# in_onesec=$in_onesec iterations\n";
 ok ($in_onesec > 0, "iters returned positive iterations");
-my $cpu1 = $onesec->[1] + $onesec->[2]; # user + sys
-cmp_ok($cpu1, '>=', 1.0, "is cpu1 is at least 1s");
+my $cpu1 = $onesec->[1]; # user
+my $sys1 = $onesec->[2]; # sys
+cmp_ok($cpu1+$sys1, '>=', 1.0, "is cpu1 is at least 1s");
 my $in_onesec_adj = $in_onesec;
 $in_onesec_adj *= (1/$cpu1); # adjust because may not have run for exactly 1s
 print "# in_onesec_adj=$in_onesec_adj adjusted iterations\n";
@@ -92,10 +94,12 @@ print "# in_onesec_adj=$in_onesec_adj adjusted iterations\n";
        diag("  in_threesecs     = $in_threesecs");
        diag("  in_threesecs_adj = $in_threesecs_adj");
        diag("  cpu3             = $cpu3");
+       diag("  sys3             = $sys3");
        diag("  estimate         = $estimate");
        diag("  in_onesec        = $in_onesec");
        diag("  in_onesec_adj    = $in_onesec_adj");
        diag("  cpu1             = $cpu1");
+       diag("  sys1             = $sys1");
     };
 }