Changeset 703 for trunk/lib


Ignore:
Timestamp:
Oct 3, 2019 7:39:25 PM (5 years ago)
Author:
anonymous
Message:

Apply rounding to ScriptTimer? getTime() output

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/ScriptTimer.inc.php

    r502 r703  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    2727{
    2828
    29     public $time_format = '%.3f';
     29    public $time_format = '%.4F';
    3030    protected $_timing_start_times = array();
    3131    protected $_timing_stop_times = array();
    3232    protected $_timing_cumulative_times = array();
    33    
     33
    3434    public function start($name='default')
    3535    {
    3636        $this->_timing_start_times[$name] = explode(' ', microtime());
    3737    }
    38    
     38
    3939    public function stop($name='default')
    4040    {
     
    4646        $this->_timing_cumulative_times[$name] += $this->getTime($name);
    4747    }
    48    
     48
    4949    public function getTime($name='default')
    5050    {
     
    6060        $current = $stop_time[1] - $this->_timing_start_times[$name][1];
    6161        $current += $stop_time[0] - $this->_timing_start_times[$name][0];
    62         return $current;
     62        return sprintf($this->time_format, $current);
    6363    }
    64    
     64
    6565    public function printAll($sort_by_time=false)
    6666    {
     
    6868        sort($names);
    6969        $name_len = end($names);
    70        
     70
    7171        if ($sort_by_time) {
    7272           arsort($this->_timing_cumulative_times, SORT_NUMERIC);
    7373        }
    74        
     74
    7575        $this->_timing_cumulative_times['TOTAL'] = array_sum($this->_timing_cumulative_times);
    7676
Note: See TracChangeset for help on using the changeset viewer.