* @license PHP License * @package WB * @subpackage base */ /** * General purpose stopwatch * * Tiny stopwatch * * @version 0.1.1 * @package WB * @subpackage base */ abstract class WBClock extends WBStdClass { /** * get current time * * @return float */ static public function now() { return microtime( true ); } /** * stop watch * * Calculate time between $start and now * * @param float $start * @param int $factor * @param int $digits * @return string */ static public function stop( $start = null, $factor = 1000, $digits = 3 ) { $now = self::now(); if( $start == null ) { $start = WBParam::get( 'wb/time/genesis' ); } $elapsed = $now - $start; if( $factor ) { $elapsed *= $factor; } return number_format( $elapsed, $digits, '.', '' ); } } ?>