Last active
August 29, 2015 14:11
-
-
Save sunny/c47982974f749da82b6f to your computer and use it in GitHub Desktop.
Benchmark with iterations shortcut
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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