timer_stop( int|bool $display, int $precision = 3 )
Retrieve or display the time from the page start to when function is called.
Description Description
Parameters Parameters
- $display
-
(int|bool) (Required) Whether to echo or return the results. Accepts 0|false for return, 1|true for echo. Default 0|false.
- $precision
-
(int) (Optional) The number of digits from the right of the decimal to display.
Default value: 3
Return Return
(string) The "second.microsecond" finished time calculation. The number is formatted for human consumption, both localized and rounded.
Source Source
File: 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;
}
Expand full source code Collapse full source code View on Trac
Changelog Changelog
| Version | Description |
|---|---|
| 0.71 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Determine length of time to render page with a precision of 3, 5 and 10 digits.
Output:
Check the Pages load Time in seconds
add_action( 'wp_footer', function() { echo '<br/>' . 'The page is loaded in ' . timer_stop() . ' seconds <br/>'; }, PHP_INT_MAX );