diff --git a/wp-includes/load.php b/wp-includes/load.php index d72066e30d..61dab0e358 100644 --- a/wp-includes/load.php +++ b/wp-includes/load.php @@ -182,17 +182,16 @@ function wp_maintenance() { } /** - * PHP 4 standard microtime start capture. + * PHP 5 standard microtime start capture. * * @access private * @since 0.71 - * @global int $timestart Seconds and microseconds added together from when function is called. + * @global float $timestart Seconds from when function is called. * @return bool Always returns true. */ function timer_start() { global $timestart; - $mtime = explode( ' ', microtime() ); - $timestart = $mtime[1] + $mtime[0]; + $timestart = microtime( true ); return true; } @@ -213,8 +212,8 @@ function timer_start() { * in most cases, you only need to echo it. * * @since 0.71 - * @global int $timestart Seconds and microseconds added together from when timer_start() is called - * @global int $timeend Seconds and microseconds added together from when function is called + * @global float $timestart Seconds from when timer_start() is called + * @global float $timeend Seconds from when function is called * * @param int $display Use '0' or null to not echo anything and 1 to echo the total time * @param int $precision The amount of digits from the right of the decimal to display. Default is 3. @@ -222,9 +221,7 @@ function timer_start() { */ function timer_stop( $display = 0, $precision = 3 ) { // if called like timer_stop(1), will echo $timetotal global $timestart, $timeend; - $mtime = microtime(); - $mtime = explode( ' ', $mtime ); - $timeend = $mtime[1] + $mtime[0]; + $timeend = microtime( true ); $timetotal = $timeend - $timestart; $r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision ); if ( $display ) diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index ce28397a76..1c058a35b7 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -1441,8 +1441,7 @@ class wpdb { * @return true */ function timer_start() { - $mtime = explode( ' ', microtime() ); - $this->time_start = $mtime[1] + $mtime[0]; + $this->time_start = microtime( true ); return true; } @@ -1451,13 +1450,10 @@ class wpdb { * * @since 1.5.0 * - * @return int Total time spent on the query, in milliseconds + * @return float Total time spent on the query, in seconds */ function timer_stop() { - $mtime = explode( ' ', microtime() ); - $time_end = $mtime[1] + $mtime[0]; - $time_total = $time_end - $this->time_start; - return $time_total; + return ( microtime( true ) - $this->time_start ); } /**