Class: Metriks::Timer
- Inherits:
-
Object
- Object
- Metriks::Timer
- Defined in:
- lib/metriks/timer.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Context
Instance Attribute Summary collapse
-
#reset_on_submit ⇒ Object
I want to get mean value for last minute only not for eternity.
Instance Method Summary collapse
-
#activate_reset_on_submit ⇒ Object
shortcut for onliners.
- #clear ⇒ Object
- #count ⇒ Object
- #fifteen_minute_rate ⇒ Object
- #five_minute_rate ⇒ Object
-
#initialize(histogram = Metriks::Histogram.new_exponentially_decaying) ⇒ Timer
constructor
A new instance of Timer.
- #max ⇒ Object
- #mean ⇒ Object
- #mean_rate ⇒ Object
- #min ⇒ Object
- #one_minute_rate ⇒ Object
- #snapshot ⇒ Object
- #stddev ⇒ Object
- #stop ⇒ Object
- #time(callable = nil, &block) ⇒ Object
- #update(duration) ⇒ Object
Constructor Details
Instance Attribute Details
#reset_on_submit ⇒ Object
I want to get mean value for last minute only not for eternity
10 11 12 |
# File 'lib/metriks/timer.rb', line 10 def reset_on_submit @reset_on_submit end |
Instance Method Details
#activate_reset_on_submit ⇒ Object
shortcut for onliners
32 33 34 35 |
# File 'lib/metriks/timer.rb', line 32 def activate_reset_on_submit @reset_on_submit = true self end |
#clear ⇒ Object
37 38 39 40 |
# File 'lib/metriks/timer.rb', line 37 def clear @meter.clear @histogram.clear end |
#count ⇒ Object
68 69 70 |
# File 'lib/metriks/timer.rb', line 68 def count @histogram.count end |
#fifteen_minute_rate ⇒ Object
80 81 82 |
# File 'lib/metriks/timer.rb', line 80 def fifteen_minute_rate @meter.fifteen_minute_rate end |
#five_minute_rate ⇒ Object
76 77 78 |
# File 'lib/metriks/timer.rb', line 76 def five_minute_rate @meter.five_minute_rate end |
#max ⇒ Object
92 93 94 |
# File 'lib/metriks/timer.rb', line 92 def max @histogram.max end |
#mean ⇒ Object
96 97 98 |
# File 'lib/metriks/timer.rb', line 96 def mean @histogram.mean end |
#mean_rate ⇒ Object
84 85 86 |
# File 'lib/metriks/timer.rb', line 84 def mean_rate @meter.mean_rate end |
#min ⇒ Object
88 89 90 |
# File 'lib/metriks/timer.rb', line 88 def min @histogram.min end |
#one_minute_rate ⇒ Object
72 73 74 |
# File 'lib/metriks/timer.rb', line 72 def one_minute_rate @meter.one_minute_rate end |
#snapshot ⇒ Object
64 65 66 |
# File 'lib/metriks/timer.rb', line 64 def snapshot @histogram.snapshot end |
#stddev ⇒ Object
100 101 102 |
# File 'lib/metriks/timer.rb', line 100 def stddev @histogram.stddev end |
#stop ⇒ Object
104 105 106 |
# File 'lib/metriks/timer.rb', line 104 def stop @meter.stop end |
#time(callable = nil, &block) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/metriks/timer.rb', line 49 def time(callable = nil, &block) callable ||= block context = Context.new(self) if callable.nil? return context end begin return callable.call ensure context.stop end end |
#update(duration) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/metriks/timer.rb', line 42 def update(duration) if duration >= 0 @meter.mark @histogram.update(duration) end end |