timer_start()
Starts the timer for the beginning of the WordPress loading.
Technically, the function sets the global variable $timestart, which records the timestamp (with microseconds) from which the loading of the WordPress core began.
global $timestart; $timestart = microtime( true );
The function is called at the beginning of the WordPress core loading, after the critically necessary components for the core loading have been set. See wp-settings.php.
This function is the basis for the timer_stop(), which gets the time difference from the moment this function was called. This is needed to measure the execution time of WordPress up to a certain point in the code.
This function should never be called manually!
Calling this function again resets the global variable $timestart.
See timer_float() — a newer version of time measurement introduced in WP 5.8.
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Returns
true|false. Always returns true.
Usage
timer_start();
Examples
#1 It's internal function
This function is called by WP itself and it makes no sense to show an example of how it works.
See examples of timer_stop(), which works in conjunction with this function.
Notes
- Global. float. $timestart Unix timestamp set at the beginning of the page load.
- See: timer_stop()
Changelog
| Since 0.71 | Introduced. |
timer_start() timer start code WP 6.8.3
function timer_start() {
global $timestart;
$timestart = microtime( true );
return true;
}