Partial fix to bug 23167
[lhc/web/wiklou.git] / includes / Profiler.php
index 817b71a..4c4aa24 100644 (file)
@@ -61,6 +61,7 @@ if (!function_exists('memory_get_usage')) {
 class Profiler {
        var $mStack = array (), $mWorkStack = array (), $mCollated = array ();
        var $mCalls = array (), $mTotals = array ();
+       var $mTemplated = false;
 
        function __construct() {
                // Push an entry for the pre-profile setup time onto the stack
@@ -139,6 +140,14 @@ class Profiler {
                }
        }
 
+       /**
+        * Mark this call as templated or not
+        * @param $t Boolean
+        */
+       function setTemplated( $t ) {
+               $this->mTemplated = $t;
+       }
+
        /**
         * called by wfGetProfilingOutput()
         */
@@ -275,9 +284,9 @@ class Profiler {
                                $overheadInternal[] = $elapsed;
                        }
                }
-               $overheadTotal = array_sum( $overheadTotal ) / count( $overheadInternal );
-               $overheadMemory = array_sum( $overheadMemory ) / count( $overheadInternal );
-               $overheadInternal = array_sum( $overheadInternal ) / count( $overheadInternal );
+               $overheadTotal = $overheadTotal ? array_sum( $overheadTotal ) / count( $overheadInternal ) : 0;
+               $overheadMemory = $overheadMemory ? array_sum( $overheadMemory ) / count( $overheadInternal ) : 0;
+               $overheadInternal = $overheadInternal ? array_sum( $overheadInternal ) / count( $overheadInternal ) : 0;
 
                # Collate
                foreach( $this->mStack as $index => $entry ){