This function will return the current time in seconds and microseconds. This is sometimes useful to track down the processing time of a script or other short lasting events.

<p>This function will return the current time in seconds and microseconds. This is sometimes useful to track down the processing time of a script or other short lasting events.</p>
 
<code class="prettyprint">
function microtime_float()
{
    list($usec, $sec) = explode(" ", microtime());
    return ((float)$usec + (float)$sec);
}
</code>
 
<p>An example usage could look like this:</p>
<code class="prettyprint">
$start = microtime_float();
 
// your code here
 
$took = round(microtime_float() - $start, 2);
 
echo "took $took seconds.";
</code>

Bookmark this!

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • del.icio.us
  • Digg
  • Fark
  • Furl
  • MisterWong
  • NewsVine
  • Reddit
  • Spurl
  • StumbleUpon
  • TailRank
  • Technorati

Submit your comment

vision22.net

Copyright © 2007