Skip to content

Commit

Permalink
force the main benchmark script to use STDOUT
Browse files Browse the repository at this point in the history
  • Loading branch information
Chuck Remes committed Mar 5, 2011
1 parent 78a85f6 commit ede7efb
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions benchmark/bin/benchmark
Expand Up @@ -62,7 +62,7 @@ if targets.empty?
end

if save and targets.size > 1
puts "Save mode only available with one target."
STDOUT.puts "Save mode only available with one target."
exit 1
end

Expand All @@ -75,7 +75,7 @@ end
results = targets.map do |t|
tf = Tempfile.new "benchmark"
tf.close
puts "=== #{t} ===" unless at_end
STDOUT.puts "=== #{t} ===" unless at_end

args = extra + ["-I#{lib_path}", "benchmark/lib/benchmark/suite-run.rb"]

Expand All @@ -100,12 +100,12 @@ if save
f << Marshal.dump(data)
end

puts "[Saved results to '#{save}']"
STDOUT.puts "[Saved results to '#{save}']"
end

if at_end
results.each do |name, suite|
puts "=== #{name} ==="
STDOUT.puts "=== #{name} ==="
suite.display
end
end
Expand All @@ -125,11 +125,11 @@ if results.size > 1
end
end

puts
STDOUT.puts

compared.each do |name, reports|
if reports.size > 1
puts "Comparing #{name}:"
STDOUT.puts "Comparing #{name}:"

iter = false
sorted = reports.sort do |a,b|
Expand All @@ -145,19 +145,19 @@ if results.size > 1


if iter
printf "%20s: %10d i/s\n", best_name, best_report.ips
STDOUT.printf "%20s: %10d i/s\n", best_name, best_report.ips
else
puts "#{best_name.rjust(20)}: #{best_report.runtime}s"
STDOUT.puts "#{best_name.rjust(20)}: #{best_report.runtime}s"
end

sorted.each do |entry|
name, report = entry
if iter
x = (best_report.ips.to_f / report.ips.to_f)
printf "%20s: %10d i/s - %.2fx slower\n", name, report.ips, x
STDOUT.printf "%20s: %10d i/s - %.2fx slower\n", name, report.ips, x
else
x = "%.2f" % (report.ips.to_f / best_report.ips.to_f)
puts "#{name.rjust(20)}: #{report.runtime}s - #{x}x slower"
STDOUT.puts "#{name.rjust(20)}: #{report.runtime}s - #{x}x slower"
end
end
end
Expand Down

0 comments on commit ede7efb

Please sign in to comment.