Ignore:
Timestamp:
May 3, 2014 11:09:03 PM (10 years ago)
Author:
anonymous
Message:

Convert tabs to spaces, and lineendings to LF in all files.

File:
1 edited

Legend:

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

    r468 r479  
    3131    private $_timing_cumulative_times = array();
    3232   
    33     public function start($name='default')
    34     {
     33    public function start($name='default')
     34    {
    3535        $this->_timing_start_times[$name] = explode(' ', microtime());
    36     }
    37    
    38     public function stop($name='default')
    39     {
    40         if (!isset($this->_timing_stop_times[$name]) || !isset($this->_timing_cumulative_times[$name])) {
    41             $this->_timing_stop_times[$name] = null;
    42             $this->_timing_cumulative_times[$name] = null;
    43         }
     36    }
     37   
     38    public function stop($name='default')
     39    {
     40        if (!isset($this->_timing_stop_times[$name]) || !isset($this->_timing_cumulative_times[$name])) {
     41            $this->_timing_stop_times[$name] = null;
     42            $this->_timing_cumulative_times[$name] = null;
     43        }
    4444        $this->_timing_stop_times[$name] = explode(' ', microtime());
    4545        $this->_timing_cumulative_times[$name] += $this->getTime($name);
    46     }
    47    
    48     public function getTime($name='default')
    49     {
     46    }
     47   
     48    public function getTime($name='default')
     49    {
    5050        if (!isset($this->_timing_start_times[$name])) {
    51             return 0;
     51            return 0;
    5252        }
    5353        if (!isset($this->_timing_stop_times[$name])) {
     
    6060        $current += $stop_time[0] - $this->_timing_start_times[$name][0];
    6161        return $current;
    62     }
    63    
    64     public function printAll($sort_by_time=false)
    65     {
    66         $names = array_map('strlen', array_keys($this->_timing_start_times));
    67         sort($names);
    68         $name_len = end($names);
    69        
    70         if ($sort_by_time) {
    71            arsort($this->_timing_cumulative_times, SORT_NUMERIC);
    72         }
    73        
    74         $this->_timing_cumulative_times['TOTAL'] = array_sum($this->_timing_cumulative_times);
     62    }
     63   
     64    public function printAll($sort_by_time=false)
     65    {
     66        $names = array_map('strlen', array_keys($this->_timing_start_times));
     67        sort($names);
     68        $name_len = end($names);
     69       
     70        if ($sort_by_time) {
     71           arsort($this->_timing_cumulative_times, SORT_NUMERIC);
     72        }
     73       
     74        $this->_timing_cumulative_times['TOTAL'] = array_sum($this->_timing_cumulative_times);
    7575
    7676        echo '<pre>';
    77         foreach ($this->_timing_cumulative_times as $name => $time) {
    78             printf("\n%-{$name_len}s $this->time_format", $name, $time);
    79         }
     77        foreach ($this->_timing_cumulative_times as $name => $time) {
     78            printf("\n%-{$name_len}s $this->time_format", $name, $time);
     79        }
    8080        echo '</pre>';
    81     }
     81    }
    8282}
Note: See TracChangeset for help on using the changeset viewer.