r108967 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108966‎ | r108967 | r108968 >
Date:11:42, 15 January 2012
Author:ialex
Status:ok
Tags:
Comment:
* Fix Profiler::getUserTime() to return a float and not string with space separated values since, was breaking difference calculation since PHP doesn't know how to make the difference of two strings :P
* Same when adding fake items in the stack after a profiling error
* Removed useless ProfilerSimple::getTime()
Modified paths:
  • /trunk/phase3/includes/profiler/Profiler.php (modified) (history)
  • /trunk/phase3/includes/profiler/ProfilerSimple.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/profiler/ProfilerSimple.php
@@ -115,13 +115,4 @@
116116 return 0;
117117 }
118118 }
119 -
120 - /* If argument is passed, it assumes that it is dual-format time string, returns proper float time value */
121 - function getTime($time=null) {
122 - if ($time==null) {
123 - return microtime(true);
124 - }
125 - list($a,$b)=explode(" ",$time);
126 - return (float)($a+$b);
127 - }
128119 }
Index: trunk/phase3/includes/profiler/Profiler.php
@@ -150,12 +150,12 @@
151151 if( $functionname == 'close' ){
152152 $message = "Profile section ended by close(): {$bit[0]}";
153153 $this->debug( "$message\n" );
154 - $this->mStack[] = array( $message, 0, '0 0', 0, '0 0', 0 );
 154+ $this->mStack[] = array( $message, 0, 0.0, 0, 0.0, 0 );
155155 }
156156 elseif( $bit[0] != $functionname ){
157157 $message = "Profiling error: in({$bit[0]}), out($functionname)";
158158 $this->debug( "$message\n" );
159 - $this->mStack[] = array( $message, 0, '0 0', 0, '0 0', 0 );
 159+ $this->mStack[] = array( $message, 0, 0.0, 0, 0.0, 0 );
160160 }
161161 //}
162162 $bit[] = $time;
@@ -265,13 +265,13 @@
266266 if ( $this->mTimeMetric === 'user' ) {
267267 return $this->getUserTime();
268268 } else {
269 - return microtime(true);
 269+ return microtime( true );
270270 }
271271 }
272272
273273 function getUserTime() {
274274 $ru = getrusage();
275 - return $ru['ru_utime.tv_sec'].' '.$ru['ru_utime.tv_usec'] / 1e6;
 275+ return $ru['ru_utime.tv_sec'] + $ru['ru_utime.tv_usec'] / 1e6;
276276 }
277277
278278 protected function collateData() {

Status & tagging log