Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.2.9

Bug #4346 [Timer.php] Bug in $result array in getProfiling() method
Submitted: 2005-05-14 19:42 UTC
From: sebastian at thornet dot net Assigned: toggg
Status: Closed Package: Benchmark
PHP Version: 5.0.3 OS: any
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 32 - 29 = ?

 
 [2005-05-14 19:42 UTC] sebastian at thornet dot net
Description: ------------ I think there is a bug in the getProfiling() method in Benchmark_Timer class. The $profiling[x]['total'] is equal to time index of marker x. Also look at in description of this method: '$profiling[x]['total'] = total execution time up to marker x' but in the array we've got a time index not execution time! Reproduce code: --------------- if (extension_loaded('bcmath')) { $diff = bcsub($time, $temp, 6); $total = bcadd($total, $diff, 6); } else { $diff = $time - $temp; $total = $total + $diff; } Expected result: ---------------- In every marker $result[$i]['total'] == $result[$i]['time'] Actual result: -------------- This should resolve the problem: if ($i == 0) $f_time = $time; if (extension_loaded('bcmath')) { $diff = bcsub($time, $temp, 6); $total = bcsub($time, $f_time, 6); } else { $diff = $time - $temp; $total = $time - $f_time; }

Comments

 [2005-05-17 13:49 UTC] tpavlakos at yahoo dot gr
[referring to the foreach loop, inside getProfiling function] I think the correct solution would be to keep $diff in the correct state all the time (i.e. not letting it have a wrong value for $i=0 inside the loop and then fixing this value later on). Apart from code clarity, this seems to be the reason for the introduction of the bug (if you ask me anyway...) ==CODE== $diff = 0 ... foreach ($this->markers as $marker => $time) { if (extension_loaded('bcmath')) { $diff = ( $i == 0 ? 0 : bcsub($time, $temp, 6) ); $total = bcadd($total, $diff, 6); } else { $diff = ( $i == 0 ? 0 : $time - $temp ); $total = $total + $diff; } and then delete the folowing line: $result[0]['diff'] = '-';
 [2005-05-24 13:49 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!