Browse files

fix for average computation

1 parent 0625731 commit 617dc480d53f37e3c4968074df2c3cf73373220e antirez committed Mar 13, 2011
Showing with 3 additions and 0 deletions.
  1. +3 −0 redis-sampler.rb
View
3 redis-sampler.rb
@@ -171,6 +171,9 @@ def compute_avg(hash)
min = k if !min or min > k
max = k if !max or max < k
}
+ if items.to_i == 0
+ return {:avg => 0, :stddev => 0, :min => 0, :max => 0}
+ end
avg /= items.to_f
# Compute standard deviation
stddev = 0

0 comments on commit 617dc48

Please sign in to comment.