datatable.directory codebase
https://datatable.directory/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
693 B
45 lines
693 B
6 years ago
|
<?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);
|
||
|
}
|
||
|
}
|