xhprof: Guard against division by 0
authorBryan Davis <bd808@wikimedia.org>
Thu, 18 Dec 2014 16:29:36 +0000 (09:29 -0700)
committerBryan Davis <bd808@wikimedia.org>
Thu, 18 Dec 2014 16:29:36 +0000 (09:29 -0700)
Warning: Division by zero in
/srv/mediawiki/php-1.25wmf12/includes/profiler/ProfilerXhprof.php on
line 143

Change-Id: Ibb3d0ce836d30663c511809b6e1dece4baa4da92

includes/profiler/ProfilerXhprof.php

index e466657..624433b 100644 (file)
@@ -145,7 +145,7 @@ class ProfilerXhprof extends Profiler {
                        }
 
                        // @note: getFunctionStats() values already in ms
-                       $stats['%real'] = $stats['real'] / $main['real'] * 100;
+                       $stats['%real'] = $main['real'] ? $stats['real'] / $main['real'] * 100 : 0;
                        $stats['%cpu'] = $main['cpu'] ? $stats['cpu'] / $main['cpu'] * 100 : 0;
                        $stats['%memory'] = $main['memory'] ? $stats['memory'] / $main['memory'] * 100 : 0;
                        $profile[] = $stats; // assume no section names collide with $metrics