mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Bootstrap/Load: Add Function for reliable timing data
Adds timer_float which can be used to get the time elapsed so far during the PHP script. Should make it easier to display the page generation time in the footer of admin. WordPress should expose timing data as a float in the most accurate manner possible. timer_stop() has two problems: it uses an initial timestamp generated later than it needs to be and its formatted return value can not reliably be used as a number (some locales swap commas and periods, for example). Props andy, matt, jorbin. Fixes #39163. git-svn-id: https://develop.svn.wordpress.org/trunk@50786 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -333,6 +333,19 @@ function wp_is_maintenance_mode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the time elapsed so far during this PHP script.
|
||||
*
|
||||
* Uses REQUEST_TIME_FLOAT that appeared in PHP 5.4.0.
|
||||
*
|
||||
* @since 5.8.0
|
||||
*
|
||||
* @return float Seconds since the PHP script started.
|
||||
*/
|
||||
function timer_float() {
|
||||
return microtime( true ) - $_SERVER['REQUEST_TIME_FLOAT'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the WordPress micro-timer.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user