note 72507 added to function.microtime
| From: | php-general at lists dot php dot net | Date: | Mon, 22 Jan 2007 06:54:45 +0000 |
| Subject: | note 72507 added to function.microtime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-122026@lists.php.net to get a copy of this message | ||
Here is a simple script to ger the script execution time, with only as many decimals as nessecary.
<?PHP
$request_time = microtime(true);
usleep(3000000);
$current_time = microtime(true);
$difference = $current_time-$request_time;
$decimals = strspn($difference, "0.", 2, 15);
$load_time = substr($difference, 0, $decimals+3);
echo "Load time: $load_time seconds";
?>
If $difference is something like 3.0245261192322, $load_time will return 3.02 seconds.
If $difference is something like 2.9995510578156, $load_time will return 2.9 seconds.
If $difference is something like 0.0006799697875, $load_time will return 0.0006 seconds.
Only the minimal number of decimals will be displayed.
----
Server IP: 193.27.201.10 (proxied: 193.27.201.10 1.0 www1.shellkonto.se:3128 (squid/2.5.STABLE4))
Probable Submitter: 87.227.26.45
----
Manual Page -- http://www.php.net/manual/en/function.microtime.php
Edit -- https://master.php.net/note/edit/72507
Del: integrated -- https://master.php.net/note/delete/72507/integrated
Del: useless -- https://master.php.net/note/delete/72507/useless
Del: bad code -- https://master.php.net/note/delete/72507/bad+code
Del: spam -- https://master.php.net/note/delete/72507/spam
Del: non-english -- https://master.php.net/note/delete/72507/non-english
Del: in docs -- https://master.php.net/note/delete/72507/in+docs
Del: other reasons-- https://master.php.net/note/delete/72507
Reject -- https://master.php.net/note/reject/72507
Search -- https://master.php.net/manage/user-notes.php