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

Bug #8748 class destructor behavior
Submitted: 2006-09-20 22:02 UTC
From: tkirby at vabest dot com Assigned: anant
Status: Closed Package: Benchmark (version 1.2.6)
PHP Version: 4.3.11 OS: linux 2.6.8-022stab067.1-enterpr
Roadmaps: (Not assigned)    
Subscription  


 [2006-09-20 22:02 UTC] tkirby at vabest dot com (Tom Kirby)
Description: ------------ php class destructors behave differently in php 4.3.11 and php 5.1.6 (probably others, too). In 4.3.11, destructor is called AFTER class storage has been released. In 5.1.6 destructor is called BEFORE class storage has been released. Problem shows up when using Benchmark in auto mode. initialize class, add markers, execution ends, then table is automatically displayed showing markers. But, no markers are displayed in 4.3.11 because marker storage was whacked before the destructor was called. Fix: in Timer.php file, comment out destructor code, and add duplicate function Close, call Close when you want output (yes, auto does not work). /** * Destructor. * * @access private */ function _Benchmark_Timer() { /*if ($this->auto) { $this->stop(); $this->display(); }*/ } function Close() { if ($this->auto) { $this->stop(); $this->display(); } } Might also be present in other two files associated with Benchmark... don't have time to check yet. Test script: --------------- <?php require_once("Benchmark/Timer.php"); print phpversion()."<br>"; function wait($amount) { for ($i=0; $i < $amount; $i++) { for ($i=0; $i < 100000; $i++) $x = sin($i / 1.2340); } } $timer = new Benchmark_Timer(TRUE); $timer->setMarker("Marker1"); wait(10); $timer->setMarker("Marker2"); wait(100); $timer->setMarker("Marker3"); wait(1000); //$timer->Close(); ?> Expected result: ---------------- output should be Start, three markers, and Stop Actual result: -------------- 4.3.11 - output is Start and Stop markers only 5.1.6 - output includes three markers, too.

Comments

 [2007-05-24 05:23 UTC] anant (Anant Narayanan)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.