timer_stop
Retrieve or display the time from the page start to when function is called.
Description
Returns (string)
The "second.microsecond" finished time calculation. The number is formatted for human consumption, both localized and rounded.
Parameters (2)
- 0. $display — Optional. (int)
- Whether to echo or return the results. Accepts 0|false for return, 1|true for echo. Default 0|false.
- 1. $precision — Optional. (int) =>
3
- The number of digits from the right of the decimal to display. Default 3.
Usage
if ( !function_exists( 'timer_stop' ) ) { require_once ABSPATH . WPINC . '/load.php'; } // Whether to echo or return the results. Accepts 0|false for return, // 1|true for echo. Default 0|false. $display = -1; // The number of digits from the right of the decimal to display. // Default 3. $precision = 3; // NOTICE! Understand what this does before running. $result = timer_stop($display, $precision);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/load.php
- function timer_stop( $display = 0, $precision = 3 ) {
- global $timestart, $timeend;
- $timeend = microtime( true );
- $timetotal = $timeend - $timestart;
- $r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision );
- if ( $display )
- echo $r;
- return $r;
- }