Hi, all.
I've got a site with a ton of PHP documents on it, and I'm interested in collecting some statistics about them.
Is there any way, short of adding logging code to each document, for me to keep records of
a) how long a given script takes to execute, and
b) how many individual database queries it generates?
I'm just trying to figure out which portions of the code need to be better streamlined.
Thanks,
El Perezoso
Tracking PHP script behavior and execution times
Moderator: General Moderators
-
ElPerezoso
- Forum Newbie
- Posts: 2
- Joined: Fri Apr 25, 2003 7:25 pm
Script execution time, or parsetime..
Create a file "parsetime.php" with the following contents..
At the top of the script, where it needs to start timing the execution, add..
At the end of the script, where the timing needs to stop and display the execution time..
Create a file "parsetime.php" with the following contents..
Code: Select all
<?php
class parsetime {
var $start;
var $stop;
function start() {
list($usec, $sec) = explode(' ', microtime());
$this->start = (float)$usec + (float)$sec;
}
function stop() {
list($usec, $sec) = explode(' ', microtime());
$this->stop = (float)$usec + (float)$sec;
return number_format($this->stop - $this->start, 4);
}
}
?>At the top of the script, where it needs to start timing the execution, add..
Code: Select all
<?php
require("parsetime.php");
$parsetime = new parsetime();
$parsetime->start();
?>Code: Select all
<?php= $parsetime->stop(); ?>