Advertisements

timer_stop

Definition:
function timer_stop( $display = 0, $precision = 3 ) { // if called like timer_stop(1), will echo $timetotal

Return and/or display the time from the page start to when function is called.
You can get the results and print them by doing:

Parameters

  • int $display: Use ‘0’ or null to not echo anything and 1 to echo the total time
  • int $precision: The amount of digits from the right of the decimal to display. Default is 3.

Return values

returns:The "second.microsecond" finished time calculation

Source code

function timer_stop( $display = 0, $precision = 3 ) { // if called like timer_stop(1), will echo $timetotal

	global $timestart, $timeend;

	$mtime = microtime();

	$mtime = explode( ' ', $mtime );

	$timeend = $mtime[1] + $mtime[0];

	$timetotal = $timeend - $timestart;

	$r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision );

	if ( $display )

		echo $r;

	return $r;

}

3063

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: