isExpensive get default value
[lhc/web/wiklou.git] / includes / Profiling.php
index 1bdf3fb..ed58bf0 100755 (executable)
@@ -1,4 +1,4 @@
-<?
+<?php
 # This file is only included if profiling is enabled
 function wfProfileIn( $functionname )
 {
@@ -82,6 +82,7 @@ class Profiler
                if( !count( $this->mStack ) ) {
                        return "No profiling output\n";
                }
+               $this->close();
                $width = 125;
                $format = "%-" . ($width - 28) . "s %6d %6.3f %6.3f %6.3f%%\n";
                $titleFormat = "%-" . ($width - 28) . "s %9s %9s %9s %9s\n";
@@ -108,11 +109,17 @@ class Profiler
                        $end = explode( " ", $entry[3]);
                        $end = (float)$end[0] + (float)$end[1];
                        $elapsed = $end - $start;
+                       
+                       if ( !array_key_exists( $fname, $this->mCollated ) ) {
+                               $this->mCollated[$fname] = 0;
+                               $this->mCalls[$fname] = 0;
+                       }
+
                        $this->mCollated[$fname] += $elapsed;
                        $this->mCalls[$fname] ++;
                }
 
-               $total = $this->mCollated["-total"];
+               $total = @$this->mCollated["-total"];
                $overhead = $this->mCollated["-overhead-internal"] / $profileCount;
                $this->mCalls["-overhead-total"] = $profileCount;
 
@@ -167,5 +174,4 @@ class Profiler
 
 $wgProfiler = new Profiler();
 $wgProfiler->profileIn( "-total" );
-
 ?>