Created
February 8, 2011 11:01
-
-
Save peterlozano/816273 to your computer and use it in GitHub Desktop.
Measure the time spent in a piece of code. Extracted from Drupal database layer.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
list($usec, $sec) = explode(' ', microtime()); | |
$timer = (float)$usec + (float)$sec; | |
// | |
// YOUR CODE HERE | |
// | |
list($usec, $sec) = explode(' ', microtime()); | |
$stop = (float)$usec + (float)$sec; | |
$diff = $stop - $timer; | |
// Diff contains a float in seconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment