Created
June 8, 2012 06:40
-
-
Save barryo/2893980 to your computer and use it in GitHub Desktop.
The most simple timing tool for PHP
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 | |
require_once( 'Timer.php' ); | |
Timer::start(); | |
// do something | |
echo "Time elapsed: " . Timer::end() . "\n"; | |
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 | |
class Timer | |
{ | |
static private $_start = null; | |
static public function start() | |
{ | |
self::$_start = microtime( true ); | |
} | |
static public function end() | |
{ | |
return self::$_time = microtime( true ) - self::$_start; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment