Re: Timing PHP code

From: Date: Tue, 28 Nov 2000 17:29:54 +0000
Subject: Re: Timing PHP code
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-27627@lists.php.net to get a copy of this message
On 28 Nov 00, at 11:57, David Diaz i Torrico wrote: > > Hi, > > I'd like to know if there's *already* any program to time a php code line > by line since I want to track all the bottlenecks in a big php page > (thousands lines of code), and I wouldn't have to do it by setting > "breakpoints" to all the functions from scratch. > > > Any ideas or suggestions will be welcomed. This isnt what you ask for of course (its not possible in the current PHP via PHP code only) but works ok for for my need.. call the report function at the end of the script.. it solved me alot of problems :) $pl_on=true; function pl_checkpoint($name) { global $pl_checkpoints,$pl_on; if ($pl_on) { $pl_checkpoints[]=array($name,doubleval(ereg_replace('^0\.([0-9]*) ([0- 9]*)$','\\2.\\1',microtime()))); }; }; function pl_report() { global $pl_checkpoints,$pl_on; if ($pl_on) { if (count($pl_checkpoints)>1) { echo "<table>"; echo "<tr><td>Checkpointname</td><td>From previous</td><td>From first one</td></tr>"; echo "<tr><td>".$pl_checkpoints[0][0]."</td><td> - </td><td> - </td></tr>"; for ($a=1;$a<count($pl_checkpoints);$a++) { echo "<tr><td>".$pl_checkpoints[$a][0]."</td>"; echo "<td>".doubleval($pl_checkpoints[$a][1]-$pl_checkpoints[$a- 1][1])."</td>"; echo "<td>".doubleval($pl_checkpoints[$a][1]- $pl_checkpoints[0][1])."</td></tr>"; }; echo "</table>"; } else { echo "No meaning in having a single checkpoint"; }; }; }; Sincerely Giovanni Tummarello tummarel@ascu.unian.it Fight Spam! Join CAUCE (Coalition Against Unsolicited Commercial Email) at http://www.cauce.org/ and tell your Congresspeople how Spam mailings hurt you. Help protect genuine Internet commerce: Outlaw UCE Spamming.

« previous php.general (#27627) next »