On Jul 14, 2003, "Marek Kilimajer" claimed that:

|I use this function:
|function echo_pt($add='') {
|   static $pt = 0;
|   if($pt==0) {
|      $pt = miro_time();
|      return;
|   }
|   $time_start = explode(' ', $pt);
|   $time_end = explode(' ', microtime());
|   $parse_time = number_format(($time_end[1] + $time_end[0] -
|       ($time_start[1] + $time_start[0])), 3);
|   echo '<!-- Parse Time '.$add.': ' . $parse_time . 's -->';
|   $pt=microtime();
|}
|
|Usage:
|it needs to be initialized first:
|echo_pt();
|then simply call as many times as you need:
|echo_pt('some string');
|and it will show you seconds elapsed from the last call to this
|function, so you can easily see where the script spends most of its
|time. Instead of echoing it you can append it to a file.
|
|Lasse Laursen wrote:
|
|> Hi all,
|>
|> We are "debugging" some web applications to try to determine where the
|> problems with long execution time is.
|>
|> Is it possible to log the execution time of each script executed to a
|> logfile? The PHP processes are run as FastCGI under Zeus.
|>
|> Regards
|> --
|> Lasse Laursen · VP, Hosting Technology · NetGroup A/S
|> St. Kongensgade 40H · DK-1264 Copenhagen K, Denmark
|> Phone: +45 3370 1526 · Fax: +45 3313 0066
|>
|> - Don't be fooled by cheap finnish imitations - BSD is the One True Code
|>
--

It seems to me that many people (usually CMS systems or shopping carts)
try to re-invent the wheel. The pear repository is filled with many
packages, hopefully more to come, and the Benchmark Package is one of
them.

require_once "Benchmark/Timer.php";
$timer = new Benchmark_Timer;
$timer -> start();
// Plenty of code...
$timer -> stop();
print("<!-- Total execution time: ");
print($timer-> timeElapsed());
print(" seconds. -->\n");

Jeff
-- 
Registered Linux user #304026.
"lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import"
Key fingerprint = 52FC 20BD 025A 8C13 5FC6  68C6 9CF9 46C2 B089 0FED
Responses to this message should conform to RFC 1855.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to