value = @date( 'Y-m-d H:i:s', $sec ) . '.' . substr( $usec, 2, 4 );
$numberOfCalls = count( self::$_times );
if ( $numberOfCalls > 0 ) { # meh, faster than count($times) > 1
$lap = $time - end( self::$_times );
self::$_laps[] = $lap;
$this->value .= "\nSINCE LAST CALL: " . round( $lap, 4 ) . 's.';
if ( $numberOfCalls > 1 ) {
$this->value .= "\nSINCE START: " . round( $time - self::$_times[0], 4 ) . 's.';
$this->value .= "\nAVERAGE DURATION: "
. round( array_sum( self::$_laps ) / $numberOfCalls, 4 ) . 's.';
}
}
$unit = array( 'B', 'KB', 'MB', 'GB', 'TB' );
if ( KINT_PHP53 ) {
$this->value .= "\nMEMORY USAGE: " . $size . " bytes ("
. round( $size / pow( 1024, ( $i = floor( log( $size, 1024 ) ) ) ), 3 ) . ' ' . $unit[ $i ] . ")";
}
self::$_times[] = $time;
$this->type = 'Stats';
}
/*
function test() {
d( 'start', microtime() );
for ( $i = 0; $i < 10; $i++ ) {
d(
$duration = mt_rand( 0, 200000 ), // the reported duration will be larger because of Kint overhead
usleep( $duration ),
microtime()
);
}
dd( );
}
*/
}