timer_stop

Retrieve or display the time from the page start to when function is called.

Description

(string) timer_stop( (int) $display = 0, (int) $precision = 3 ); 

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

  1. if ( !function_exists( 'timer_stop' ) ) { 
  2. require_once ABSPATH . WPINC . '/load.php'; 
  3.  
  4. // Whether to echo or return the results. Accepts 0|false for return, 
  5. // 1|true for echo. Default 0|false. 
  6. $display = -1; 
  7.  
  8. // The number of digits from the right of the decimal to display. 
  9. // Default 3. 
  10. $precision = 3; 
  11.  
  12. // NOTICE! Understand what this does before running. 
  13. $result = timer_stop($display, $precision); 
  14.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/load.php  
  1. function timer_stop( $display = 0, $precision = 3 ) { 
  2. global $timestart, $timeend; 
  3. $timeend = microtime( true ); 
  4. $timetotal = $timeend - $timestart; 
  5. $r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision ); 
  6. if ( $display ) 
  7. echo $r; 
  8. return $r;