Created
February 1, 2011 14:39
-
-
Save stojg/805937 to your computer and use it in GitHub Desktop.
PHP5 Utility timer for fast benchmarks of code
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 { | |
protected static $start_time = 0.00; | |
protected static $total_time = 0.00; | |
public static function start() { | |
self::$start_time = microtime(true); | |
} | |
public static function stop() { | |
$time_end = microtime(true); | |
$end_time = $time_end - self::$start_time; | |
self::$total_time = $end_time + self::$total_time; | |
return sprintf("%.3fs (%.3fs total)" ,$end_time, self::$total_time ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment