From bddbb77e99de25f767da0126370c59311540e6b8 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Sun, 15 Jan 2012 11:42:36 +0000 Subject: [PATCH] * 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() --- includes/profiler/Profiler.php | 8 ++++---- includes/profiler/ProfilerSimple.php | 9 --------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/includes/profiler/Profiler.php b/includes/profiler/Profiler.php index bb6ab13025..6deac89333 100644 --- a/includes/profiler/Profiler.php +++ b/includes/profiler/Profiler.php @@ -150,12 +150,12 @@ class Profiler { if( $functionname == 'close' ){ $message = "Profile section ended by close(): {$bit[0]}"; $this->debug( "$message\n" ); - $this->mStack[] = array( $message, 0, '0 0', 0, '0 0', 0 ); + $this->mStack[] = array( $message, 0, 0.0, 0, 0.0, 0 ); } elseif( $bit[0] != $functionname ){ $message = "Profiling error: in({$bit[0]}), out($functionname)"; $this->debug( "$message\n" ); - $this->mStack[] = array( $message, 0, '0 0', 0, '0 0', 0 ); + $this->mStack[] = array( $message, 0, 0.0, 0, 0.0, 0 ); } //} $bit[] = $time; @@ -265,13 +265,13 @@ class Profiler { if ( $this->mTimeMetric === 'user' ) { return $this->getUserTime(); } else { - return microtime(true); + return microtime( true ); } } function getUserTime() { $ru = getrusage(); - return $ru['ru_utime.tv_sec'].' '.$ru['ru_utime.tv_usec'] / 1e6; + return $ru['ru_utime.tv_sec'] + $ru['ru_utime.tv_usec'] / 1e6; } protected function collateData() { diff --git a/includes/profiler/ProfilerSimple.php b/includes/profiler/ProfilerSimple.php index bbdbec8e10..055a0ea0f7 100644 --- a/includes/profiler/ProfilerSimple.php +++ b/includes/profiler/ProfilerSimple.php @@ -115,13 +115,4 @@ class ProfilerSimple extends Profiler { return 0; } } - - /* If argument is passed, it assumes that it is dual-format time string, returns proper float time value */ - function getTime($time=null) { - if ($time==null) { - return microtime(true); - } - list($a,$b)=explode(" ",$time); - return (float)($a+$b); - } } -- 2.20.1