note 77810 added to function.register-shutdown-function

From: Date: Thu, 13 Sep 2007 16:57:14 +0000
Subject: note 77810 added to function.register-shutdown-function
Groups: php.notes 
Request: Send a blank email to php-notes+get-130471@lists.php.net to get a copy of this message
This simple function (i gues) is for measuring page generation time in microseconds, using earlier mentioned register_shutdown_function... Here is an example: <?php set_time_limit(0); function check_time($time_str, $end = false){ global $start; //Need some global variable where we will ceep our start time list($msec, $sec) = explode(' ', $time_str); $result = bcadd($msec, $sec, 10); if(!$end){ $start = $result; register_shutdown_function('check_time', microtime(), 'true'); //Function registrates itself only with some parametrs now }elseif($end){ $end = $result; echo '<br />Page was generated in '.bcsub($end, $start, 10).' seconds...<br />'; } } check_time(microtime()); //Caling our function once! //Doing some job which we will measure... $fd = fopen('users.txt', 'r'); while(!feof($fd)){ $buffer .= fread($fd, 1024); } fclose($fd); ?> As you see may be its large, but you dont have to call "check_time" function twice, in the start and at the end of the script, as many users usually do... ---- Server IP: 81.198.190.2 Probable Submitter: 213.180.122.154 ---- Manual Page -- http://www.php.net/manual/en/function.register-shutdown-function.php Edit -- https://master.php.net/note/edit/77810 Del: integrated -- https://master.php.net/note/delete/77810/integrated Del: useless -- https://master.php.net/note/delete/77810/useless Del: bad code -- https://master.php.net/note/delete/77810/bad+code Del: spam -- https://master.php.net/note/delete/77810/spam Del: non-english -- https://master.php.net/note/delete/77810/non-english Del: in docs -- https://master.php.net/note/delete/77810/in+docs Del: other reasons-- https://master.php.net/note/delete/77810 Reject -- https://master.php.net/note/reject/77810 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#130471) next »