From 926cd0afeebc5a78871d1e159dd5f679b503d80c Mon Sep 17 00:00:00 2001 From: Aaron Jorbin Date: Fri, 23 Apr 2021 19:49:05 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@50786 git-svn-id: http://core.svn.wordpress.org/trunk@50395 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/load.php | 13 +++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/wp-includes/load.php b/wp-includes/load.php index be5a8fcda7..0ea926c9dd 100644 --- a/wp-includes/load.php +++ b/wp-includes/load.php @@ -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. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 911e8d8dff..4ddd58ec76 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.8-alpha-50785'; +$wp_version = '5.8-alpha-50786'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.