Class: XSpec::Notifier::TimingsAtEnd
- Inherits:
-
Object
- Object
- XSpec::Notifier::TimingsAtEnd
- Includes:
- Composable
- Defined in:
- lib/xspec/notifiers.rb
Overview
Renders a histogram of test durations after the entire run is complete.
Constant Summary collapse
- DEFAULT_SPLITS =
[0.001, 0.005, 0.01, 0.1, 1.0, Float::INFINITY]
Instance Method Summary collapse
- #evaluate_finish(result) ⇒ Object
- #evaluate_start(_) ⇒ Object
-
#initialize(out: $stdout, splits: DEFAULT_SPLITS, width: 20) ⇒ TimingsAtEnd
constructor
A new instance of TimingsAtEnd.
- #run_finish ⇒ Object
- #run_start(*_) ⇒ Object
Methods included from Composable
Constructor Details
#initialize(out: $stdout, splits: DEFAULT_SPLITS, width: 20) ⇒ TimingsAtEnd
Returns a new instance of TimingsAtEnd.
85 86 87 88 89 90 91 92 93 |
# File 'lib/xspec/notifiers.rb', line 85 def initialize(out: $stdout, splits: DEFAULT_SPLITS, width: 20) @timings = {} @splits = splits @width = width @out = out end |
Instance Method Details
#evaluate_finish(result) ⇒ Object
100 101 102 |
# File 'lib/xspec/notifiers.rb', line 100 def evaluate_finish(result) timings[result] = result.duration end |
#evaluate_start(_) ⇒ Object
97 98 |
# File 'lib/xspec/notifiers.rb', line 97 def evaluate_start(_) end |
#run_finish ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/xspec/notifiers.rb', line 104 def run_finish buckets = bucket_from_splits(timings, splits) max = buckets.values.max out.puts " Timings:" buckets.each do |(split, count)| label = split.infinite? ? "∞" : split out.puts " %6s %-#{width}s %i" % [ label, '#' * (count / max.to_f * width.to_f).ceil, count ] end out.puts end |
#run_start(*_) ⇒ Object
95 |
# File 'lib/xspec/notifiers.rb', line 95 def run_start(*_); end |