initial
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace MightyPork\Utils;
|
||||
|
||||
|
||||
/**
|
||||
* Profiling funcs
|
||||
*/
|
||||
class Profiler
|
||||
{
|
||||
/**
|
||||
* Get current time
|
||||
*
|
||||
* @return float time (s)
|
||||
*/
|
||||
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, formatted to 3 decimal places for printing.
|
||||
*
|
||||
* @param float $start time obtained with "start()"
|
||||
* @return float time elapsed (s)
|
||||
*/
|
||||
public static function end($start)
|
||||
{
|
||||
return sprintf('%0.3f', self::now() - $start);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user