Class: Statue::Stopwatch
- Inherits:
-
Object
- Object
- Statue::Stopwatch
- Defined in:
- lib/statue/stopwatch.rb
Instance Method Summary collapse
-
#initialize(name, options = {}) ⇒ Stopwatch
constructor
A new instance of Stopwatch.
- #partial(options = {}) ⇒ Object
- #reset(options = {}) ⇒ Object
- #stop(options = {}) ⇒ Object
Constructor Details
Instance Method Details
#partial(options = {}) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/statue/stopwatch.rb', line 10 def partial( = {}) suffix = .delete(:suffix) now = .delete(:now) || Clock.now_in_ms previous, @partial = @partial, now @reporter.report_duration(metric_name(suffix || "runtime.partial"), @partial - previous, ) end |
#reset(options = {}) ⇒ Object
30 31 32 |
# File 'lib/statue/stopwatch.rb', line 30 def reset( = {}) @start = @partial = [:now] || Clock.now_in_ms end |
#stop(options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/statue/stopwatch.rb', line 18 def stop( = {}) suffix = .delete(:suffix) now = .delete(:now) || Clock.now_in_ms report_partial = .delete(:report_partial) || false partial(.merge(now: now, suffix: report_partial.is_a?(String) ? report_partial : nil)) if report_partial previous, @start = @start, now @reporter.report_duration(metric_name(suffix || "runtime.total"), @start - previous, ) end |