Make WordPress Core


Ignore:
Timestamp:
12/20/2011 09:36:53 PM (11 years ago)
Author:
nacin
Message:

Ask for a float from microtime() for timer_start(), timer_stop(). Clarify docs. props solarissmoke, fixes #19157.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/load.php

    r19593 r19611  
    183183
    184184/**
    185  * PHP 4 standard microtime start capture.
     185 * PHP 5 standard microtime start capture.
    186186 *
    187187 * @access private
    188188 * @since 0.71
    189  * @global int $timestart Seconds and microseconds added together from when function is called.
     189 * @global float $timestart Seconds from when function is called.
    190190 * @return bool Always returns true.
    191191 */
    192192function timer_start() {
    193193    global $timestart;
    194     $mtime = explode( ' ', microtime() );
    195     $timestart = $mtime[1] + $mtime[0];
     194    $timestart = microtime( true );
    196195    return true;
    197196}
     
    214213 *
    215214 * @since 0.71
    216  * @global int $timestart Seconds and microseconds added together from when timer_start() is called
    217  * @global int $timeend Seconds and microseconds added together from when function is called
     215 * @global float $timestart Seconds from when timer_start() is called
     216 * @global float $timeend Seconds from when function is called
    218217 *
    219218 * @param int $display Use '0' or null to not echo anything and 1 to echo the total time
     
    223222function timer_stop( $display = 0, $precision = 3 ) { // if called like timer_stop(1), will echo $timetotal
    224223    global $timestart, $timeend;
    225     $mtime = microtime();
    226     $mtime = explode( ' ', $mtime );
    227     $timeend = $mtime[1] + $mtime[0];
     224    $timeend = microtime( true );
    228225    $timetotal = $timeend - $timestart;
    229226    $r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision );
Note: See TracChangeset for help on using the changeset viewer.