Skip to content

Commit

Permalink
nicer progress display for meter
Browse files Browse the repository at this point in the history
  • Loading branch information
geemus committed Nov 13, 2010
1 parent f78f5f1 commit 8416a60
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/tach.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,17 @@ def initialize(times = 1, &block)
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(', ')
STDOUT.flush
end
end
print("]\n\n")
STDOUT.flush
Formatador.display_table(data, [:tach, :total])
Formatador.display_line
end
Expand All @@ -44,14 +51,14 @@ def tach(name, &block)

def run_tach(name, count, &benchmark)
GC::start
Formatador.display_line(name)
print(name)
STDOUT.flush
tach_start = Time.now
for index in 1..count
instance_eval(&benchmark)
end
tach_finish = Time.now
duration = tach_finish.to_f - tach_start.to_f
Formatador.display_line
duration
end

Expand Down

0 comments on commit 8416a60

Please sign in to comment.