note 72507 deleted from function.microtime by didou

From: Date: Mon, 22 Jan 2007 07:38:47 +0000
Subject: note 72507 deleted from function.microtime by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-122029@lists.php.net to get a copy of this message
Note Submitter: Reason: useless ---- 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.

« previous php.notes (#122029) next »