note 30495 added to function.microtime
| From: | jukkissh at hotmail dot com | Date: | Thu, 20 Mar 2003 06:17:53 +0000 |
| Subject: | note 30495 added to function.microtime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-45535@lists.php.net to get a copy of this message | ||
A nice benchmark script using microtime
===============================
<html><head><title>Speed testing</title></head><body>
<?php
$run_cycles = 1000;
echo "\n<!--\n\n";
$proctime_start=microtime(); # time calculation start-point
##################################
# One time executions
##################################
for ($pt_count = 0; $pt_count < $run_cycles; $pt_count++) {
##################################
# The actual test-cycle
##################################
} // for
##################################
list($usec_e, $sec_e) = explode(" ",microtime()); # time calculation end-point
list($usec_s, $sec_s) = explode(" ",$proctime_start);
$proctime_start = $usec_s+$sec_s;
$proctime_end = $usec_e+$sec_e;
$proctime = $proctime_end-$proctime_start;
echo "\n\n-->\n";
echo "\n\nProcessing time: " . substr($proctime,0,7);
?>
</body></html>
===============================
Remember to adjust $run_cycles if you are running complex scripts. This has proven very usefull when
testing different function combinations, which work the best on heavy load.
--
http://www.php.net/manual/en/function.microtime.php
http://master.php.net/manage/user-notes.php?action=edit+30495
http://master.php.net/manage/user-notes.php?action=delete+30495
http://master.php.net/manage/user-notes.php?action=reject+30495