Revision: 1085
Author: [email protected]
Date: Fri Feb 26 08:04:29 2010
Log: Count system cpu time as well as user time in the loop in
t/61-cputime.t.
Allow a 1% error in the profiled CPU time.
http://code.google.com/p/perl-devel-nytprof/source/detail?r=1085
Modified:
/trunk/t/61-cputime.t
=======================================
--- /trunk/t/61-cputime.t Wed Feb 24 06:48:26 2010
+++ /trunk/t/61-cputime.t Fri Feb 26 08:04:29 2010
@@ -37,7 +37,7 @@
my $sub = $subs->{'main::foo'};
ok $sub;
is $sub->calls, 1, 'main::foo should be called 1 time';
- cmp_ok $sub->incl_time, '>', 0.4, 'cputime of foo() should be at
least 0.4';
+ cmp_ok $sub->incl_time, '>=', 0.4 * 0.99, 'cputime of foo() should
be at least 0.4';
cmp_ok $sub->incl_time, '<', 1.0, 'cputime of foo() should be not
much more than 0.4';
is $sub->incl_time, $sub->excl_time, 'incl_time and excl_time
should be the same';
},
@@ -64,8 +64,8 @@
my $loops = 0;
my $prev;
while (++$loops) {
-
- my $crnt = (times)[0] - $cpu1;
+ my @times = times;
+ my $crnt = $times[0] + $times[1] - $cpu1;
warn sprintf "tick %.4f\t%f\n", $crnt, time()
if $trace >= 2 && $prev && $crnt != $prev;
$prev = $crnt;
@@ -84,8 +84,13 @@
1 while time() <= $start;
# spin till cpu clock ticks (typically 0.1 sec max)
-$cpu1 = (times)[0];
-1 while $cpu1 == ($cpu2 = (times)[0]);
+my @times = times;
+$cpu1 = $times[0] + $times[1];
+while (1) {
+ @times = times;
+ $cpu2 = $times[0] + $times[1];
+ last if $cpu2 != $cpu1;
+}
warn sprintf "step %f\t%f\n", $cpu2-$cpu1, time() if $trace;
--
You've received this message because you are subscribed to
the Devel::NYTProf Development User group.
Group hosted at: http://groups.google.com/group/develnytprof-dev
Project hosted at: http://perl-devel-nytprof.googlecode.com
CPAN distribution: http://search.cpan.org/dist/Devel-NYTProf
To post, email: [email protected]
To unsubscribe, email: [email protected]