Permalink
Browse files

making sure we have childNodes, before we calculate the trivial-time …

…threshold.

this fixes issue #4

also, found that when the global duration is 0ms (your script is super fast) there was a division error when figuring out the total query time spent. so i added a check to make sure global duration was > 0.
  • Loading branch information...
1 parent ff41fd9 commit 152b95a5926a7dc4054ca9ba540a082df689b4a4 @jimrubenstein jimrubenstein committed Jan 6, 2012
Showing with 9 additions and 6 deletions.
  1. +8 −5 profiler.php
  2. +1 −1 profiler_tpl.tpl.php
View
@@ -411,14 +411,17 @@ public function setTrivialThreshold($threshold)
*/
protected static function calculateThreshold()
{
- foreach (self::$childDurations as &$childDuration)
+ if (count(self::$childDurations))
{
- $childDuration = round($childDuration * 1000, 1);
- }
+ foreach (self::$childDurations as &$childDuration)
+ {
+ $childDuration = round($childDuration * 1000, 1);
+ }
- sort(self::$childDurations);
+ sort(self::$childDurations);
- self::$trivialThresholdMS = self::$childDurations[ floor(count(self::$childDurations) * self::$trivialThreshold) ];
+ self::$trivialThresholdMS = self::$childDurations[ floor(count(self::$childDurations) * self::$trivialThreshold) ];
+ }
}
/**
View
@@ -192,7 +192,7 @@
<a href="#" id="profiler-show-trivial_button">show trivial</a>
<a href="#" id="profiler-show-total_duration">show time w/children</a>
</td>
- <td colspan="3" class="profiler-total-querytime profiler-monospace"><?php echo round(self::getTotalQueryTime() / self::getGlobalDuration(), 2) * 100; ?><span class="unit">% in sql</span></td>
+ <td colspan="3" class="profiler-total-querytime profiler-monospace"><?php echo self::getGlobalDuration() > 0? round(self::getTotalQueryTime() / self::getGlobalDuration(), 2) * 100 : 0; ?><span class="unit">% in sql</span></td>
</tr>
</tfoot>
</table>

0 comments on commit 152b95a

Please sign in to comment.