Re: [PHP] Re: How can i calculate total process time?
Richard Lynch wrote: M. Sokolewicz wrote: JoShQuNe wrote: Hi, i wanna ask if anybody knows how to calculate the total process time. I guess there exists a function to perform but i dont know which one it is. I mean if u c any PHP Nuke site, it says this page is produced in seconds. I made some codes it calculates but i dont believe that it is equal to total process time.. Thanx.. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com fetch the microtime() at the top of the script, and at the bottom of the script you fetch it again. Subtract the first from the later, and you're left with the time it took. Then change it to a human-readable form, and you're done. You can't get closer without hacking the ZE You need to convert it to human-readable (or at least to machine-subtractable) BEFORE you substract them. http://php.net/microtime explains why. I assumed the use of microtime(true) in php 5.0.0+ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How can i calculate total process time?
M. Sokolewicz wrote: > JoShQuNe wrote: >> Hi, i wanna ask if anybody knows how to calculate the total process >> time. I guess there exists a >> function to perform but i dont know which one it is. I mean if u c any >> PHP Nuke site, it says this >> page is produced in seconds. I made some codes it calculates but i >> dont believe that it is >> equal to total process time.. Thanx.. >> >> __ >> Do You Yahoo!? >> Tired of spam? Yahoo! Mail has the best spam protection around >> http://mail.yahoo.com > fetch the microtime() at the top of the script, and at the bottom of the > script you fetch it again. Subtract the first from the later, and you're > left with the time it took. Then change it to a human-readable form, and > you're done. You can't get closer without hacking the ZE You need to convert it to human-readable (or at least to machine-subtractable) BEFORE you substract them. http://php.net/microtime explains why. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How can i calculate total process time?
Eli wrote: On top use this: On the end use this: ".round($endtime-$starttime,3)." sec"; ?> If you want a nice object oriented solution that's easy to use over and over again which does pretty much the same thing, give this class a whirl. 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 = round($this->cls_stop_time - $this->cls_start_time,5); return $this->cls_gen_time; } } then, on the page you want to time, just put at the top: require('class.pagegen.php')// OR WHATEVE YOU NAMED IT $pagegen = new page_gen(); $pagegen->start(); // START TIMING then at the end... $pagegen->stop();// STOP TIMING $pagegen->gen(); // RETURN GENERATION TIME -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How can i calculate total process time?
M. Sokolewicz wrote: fetch the microtime() at the top of the script, and at the bottom of the script you fetch it again. Subtract the first from the later, and you're left with the time it took. Then change it to a human-readable form, and you're done. You can't get closer without hacking the ZE On top use this: On the end use this: ".round($endtime-$starttime,3)." sec"; ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How can i calculate total process time?
JoShQuNe wrote: Hi, i wanna ask if anybody knows how to calculate the total process time. I guess there exists a function to perform but i dont know which one it is. I mean if u c any PHP Nuke site, it says this page is produced in seconds. I made some codes it calculates but i dont believe that it is equal to total process time.. Thanx.. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com fetch the microtime() at the top of the script, and at the bottom of the script you fetch it again. Subtract the first from the later, and you're left with the time it took. Then change it to a human-readable form, and you're done. You can't get closer without hacking the ZE -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php