Class: Rack::Mount::Analysis::Histogram
- Inherits:
-
Hash
- Object
- Hash
- Rack::Mount::Analysis::Histogram
- Defined in:
- lib/rack/mount/analysis/histogram.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
Instance Method Summary collapse
- #<<(value) ⇒ Object
-
#initialize ⇒ Histogram
constructor
A new instance of Histogram.
- #keys_in_upper_quartile ⇒ Object
- #max ⇒ Object
- #mean ⇒ Object
- #min ⇒ Object
- #sorted_by_frequency ⇒ Object
- #standard_deviation ⇒ Object
- #upper_quartile_limit ⇒ Object
Constructor Details
#initialize ⇒ Histogram
Returns a new instance of Histogram.
6 7 8 9 10 |
# File 'lib/rack/mount/analysis/histogram.rb', line 6 def initialize @count = 0 super(0) expire_caches! end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
4 5 6 |
# File 'lib/rack/mount/analysis/histogram.rb', line 4 def count @count end |
Instance Method Details
#<<(value) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/rack/mount/analysis/histogram.rb', line 12 def <<(value) @count += 1 self[value] += 1 if value expire_caches! self end |
#keys_in_upper_quartile ⇒ Object
43 44 45 |
# File 'lib/rack/mount/analysis/histogram.rb', line 43 def keys_in_upper_quartile @keys_in_upper_quartile ||= compute_keys_in_upper_quartile end |
#max ⇒ Object
23 24 25 |
# File 'lib/rack/mount/analysis/histogram.rb', line 23 def max @max ||= values.max || 0 end |
#mean ⇒ Object
31 32 33 |
# File 'lib/rack/mount/analysis/histogram.rb', line 31 def mean @mean ||= calculate_mean end |
#min ⇒ Object
27 28 29 |
# File 'lib/rack/mount/analysis/histogram.rb', line 27 def min @min ||= values.min || 0 end |
#sorted_by_frequency ⇒ Object
19 20 21 |
# File 'lib/rack/mount/analysis/histogram.rb', line 19 def sorted_by_frequency sort_by { |_, value| value }.reverse! end |
#standard_deviation ⇒ Object
35 36 37 |
# File 'lib/rack/mount/analysis/histogram.rb', line 35 def standard_deviation @standard_deviation ||= calculate_standard_deviation end |
#upper_quartile_limit ⇒ Object
39 40 41 |
# File 'lib/rack/mount/analysis/histogram.rb', line 39 def upper_quartile_limit @upper_quartile_limit ||= calculate_upper_quartile_limit end |