Skip to content

Instantly share code, notes, and snippets.

@stojg stojg/Timer.php
Created Feb 1, 2011

Embed
What would you like to do?
PHP5 Utility timer for fast benchmarks of code
<?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
You can’t perform that action at this time.