Class: Tach::Meter
- Inherits:
-
Object
- Object
- Tach::Meter
- Defined in:
- lib/tach.rb
Instance Method Summary collapse
-
#initialize(times = 1, &block) ⇒ Meter
constructor
A new instance of Meter.
- #tach(name, &block) ⇒ Object
Constructor Details
#initialize(times = 1, &block) ⇒ Meter
Returns a new instance of Meter.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/tach.rb', line 28 def initialize(times = 1, &block) @benchmarks = [] @results = {} @times = times instance_eval(&block) Formatador.display_line Formatador.display('[') data = [] for name, block in @benchmarks data << { :tach => name, :total => format("%8.6f", run_tach(name, @times, &block)) } unless [name, block] == @benchmarks.last print(', ') end end print("]\n\n") data.sort! {|x,y| x[:total].to_f <=> y[:total].to_f } Formatador.display_table(data, [:tach, :total]) Formatador.display_line end |
Instance Method Details
#tach(name, &block) ⇒ Object
50 51 52 |
# File 'lib/tach.rb', line 50 def tach(name, &block) @benchmarks << [name, block] end |