unexplainable - page generation time class

From: Date: Sun, 06 Mar 2005 05:04:41 +0000
Subject: unexplainable - page generation time class
Groups: php.general 
Request: Send a blank email to php-general+get-210079@lists.php.net to get a copy of this message
Howdy! I've made a class which simply determines the page generation time of a php script... After pretty much an hour of straight examining the code and trying tons of different things, no good has come of it, however I can't find an error... anywhere. <?php class page_gen {
       //
       // PRIVATE - DO NOT MODIFY
       //
       var $cls_start_time;
       var $cls_stop_time;
       var $cls_gen_time;
              //
       // FIGURE OUT THE TIME AT THE BEGINNING OF THE PAGE
       //
       function start() {
           $microstart = explode(' ',microtime());
           $this->cls_start_time = $microstart[0] + $microstart[1];
       }
              //
       // FIGURE OUT THE TIME AT THE END OF THE PAGE
       //
       function stop() {
           $microstop = explode(' ',microtime());
           $this->cls_stop_time = $microstop[0] + $microstop[1];
       }
              //
       // CALCULATE THE DIFFERENCE BETWEEN THE BEGINNNG AND THE END AND COLOR CODE THE RESULT
       //
       function gen() {
           $this->cls_gen_time = $this->cls_stop_time - $this->cls_start_time;
           return $this->cls_gen_time;
       }
} ?> What happens is it simply returns the $this->cls_start_time variable. Both the start() and stop() functions work fine because to test them I put print commands at the end and they both returned proper results, the error appears to be in the line where I minus the start time from the end time. It simply returns a negative start time instead of minusing the two. I tried changing the minus to a plus for testing sake and it just took out the negative. Does anybody have any idea what is going on here? Thanks-you

« previous php.general (#210079) next »