/usr/lib/ruby/vendor_ruby/benchmark/compare.rb is in ruby-benchmark-ips 1.2.0+git.20130609.e47e416-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | module Benchmark
def compare(*reports)
return if reports.size < 2
iter = false
sorted = reports.sort do |a,b|
if a.respond_to? :ips
iter = true
b.ips <=> a.ips
else
a.runtime <=> b.runtime
end
end
best = sorted.shift
STDOUT.puts "\nComparison:"
if iter
STDOUT.printf "%20s: %10.1f i/s\n", best.label, best.ips
else
STDOUT.puts "#{best.rjust(20)}: #{best.runtime}s"
end
sorted.each do |report|
name = report.label
if iter
x = (best.ips.to_f / report.ips.to_f)
STDOUT.printf "%20s: %10.1f i/s - %.2fx slower\n", name, report.ips, x
else
x = "%.2f" % (report.ips.to_f / best.ips.to_f)
STDOUT.puts "#{name.rjust(20)}: #{report.runtime}s - #{x}x slower"
end
end
STDOUT.puts
end
module_function :compare
end
|