Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php namespace MightyPork\Wrack;
- /**
- * Utility for profiling.
- */
- class Profiler
- {
- /**
- * Get current time
- *
- * @return float time with microsecond precision
- */
- public static function now()
- {
- list($usec, $sec) = explode(" ", microtime());
- return ((float) $usec + (float) $sec);
- }
- /**
- * Start profiling
- *
- * @return float current time (profiling token)
- */
- public static function start()
- {
- return self::now();
- }
- /**
- * Measure time elapsed since start
- *
- * @param float $start time obtained with "start()"
- * @return string time elapsed (s)
- */
- public static function end($start)
- {
- return sprintf('%0.3f', self::now() - $start);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment