Skip to content

Instantly share code, notes, and snippets.

@sunny
Last active August 29, 2015 14:11
Show Gist options
  • Save sunny/c47982974f749da82b6f to your computer and use it in GitHub Desktop.
Save sunny/c47982974f749da82b6f to your computer and use it in GitHub Desktop.
Benchmark with iterations shortcut
require 'benchmark'
def bmark(iterations, benches)
size = benches.keys.map(&:length).sort.last
Benchmark.bm(size) do |x|
benches.each do |key, value|
x.report(key) do
iterations.times { value.call }
end
end
end
nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment