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] 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!