From: Bryan Davis Date: Thu, 4 Dec 2014 01:48:44 +0000 (-0700) Subject: xhprof: Guard against division by 0 when computing percentages X-Git-Tag: 1.31.0-rc.0~13056^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/categories/modifier.php?a=commitdiff_plain;h=e222ba36285d5162447524291f2acafabfaacfcb;p=lhc%2Fweb%2Fwiklou.git xhprof: Guard against division by 0 when computing percentages Change-Id: Icce3b5be1136c541dc87c44b01a42709f19ca885 --- diff --git a/includes/libs/Xhprof.php b/includes/libs/Xhprof.php index 990e2c3053..98ff675c89 100644 --- a/includes/libs/Xhprof.php +++ b/includes/libs/Xhprof.php @@ -267,13 +267,16 @@ class Xhprof { foreach ( $stats as $name => $value ) { if ( $value instanceof RunningStat ) { $total = $value->m1 * $value->n; + $percent = ( isset( $main[$name] ) && $main[$name] ) + ? 100 * $total / $main[$name] + : 0; $this->inclusive[$func][$name] = array( 'total' => $total, 'min' => $value->min, 'mean' => $value->m1, 'max' => $value->max, 'variance' => $value->m2, - 'percent' => 100 * $total / $main[$name], + 'percent' => $percent, ); } }