Last active
January 23, 2020 20:42
-
-
Save mayinx/17c8a399dcad3a6a69d9c1e99a4e4144 to your computer and use it in GitHub Desktop.
Easy Ruby-Benchmarking
This file contains 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
# Easy Ruby-Benchmarking, e.g | |
require 'benchmark' | |
n = 10_000 | |
Benchmark.bm do |benchmark| | |
benchmark.report("settings") do | |
n.times do | |
d.settings(:themes).value | |
end | |
end | |
benchmark.report(" cashed ") do | |
n.times do | |
d.themes_settings_hash | |
end | |
end | |
benchmark.report("cashed iv") do | |
n.times do | |
d.themes_settings_hash(true) | |
end | |
end | |
end | |
# Output: | |
user system total real | |
settings 0.170000 0.000000 0.170000 ( 0.172577) | |
cashed 0.010000 0.000000 0.010000 ( 0.009778) | |
cashed iv 0.070000 0.000000 0.070000 ( 0.065076) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment