- Timestamp:
- Oct 3, 2019 7:39:25 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/ScriptTimer.inc.php
r502 r703 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 27 27 { 28 28 29 public $time_format = '%. 3f';29 public $time_format = '%.4F'; 30 30 protected $_timing_start_times = array(); 31 31 protected $_timing_stop_times = array(); 32 32 protected $_timing_cumulative_times = array(); 33 33 34 34 public function start($name='default') 35 35 { 36 36 $this->_timing_start_times[$name] = explode(' ', microtime()); 37 37 } 38 38 39 39 public function stop($name='default') 40 40 { … … 46 46 $this->_timing_cumulative_times[$name] += $this->getTime($name); 47 47 } 48 48 49 49 public function getTime($name='default') 50 50 { … … 60 60 $current = $stop_time[1] - $this->_timing_start_times[$name][1]; 61 61 $current += $stop_time[0] - $this->_timing_start_times[$name][0]; 62 return $current;62 return sprintf($this->time_format, $current); 63 63 } 64 64 65 65 public function printAll($sort_by_time=false) 66 66 { … … 68 68 sort($names); 69 69 $name_len = end($names); 70 70 71 71 if ($sort_by_time) { 72 72 arsort($this->_timing_cumulative_times, SORT_NUMERIC); 73 73 } 74 74 75 75 $this->_timing_cumulative_times['TOTAL'] = array_sum($this->_timing_cumulative_times); 76 76
Note: See TracChangeset
for help on using the changeset viewer.