Created
April 30, 2015 17:46
-
-
Save jonatas/6eaa699d08b507b7b7a7 to your computer and use it in GitHub Desktop.
benchmark compare
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 compare hash, options={} | |
| options[:times] ||= 10 | |
| Benchmark.bm(5) do |x| | |
| hash.each do |action, execute| | |
| x.report(action) { | |
| options[:times].times { execute.() } | |
| } | |
| end | |
| end | |
| end |
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 "compare" | |
| compare({ | |
| "YAML" => -> { YAML.load_file "config/database.yml" }, | |
| "Psych" => -> {Psych.load_file "config/database.yml"} }, { :times => 100_000 }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment