Skip to content

Instantly share code, notes, and snippets.

@mayinx
Last active January 23, 2020 20:42
Show Gist options
  • Save mayinx/17c8a399dcad3a6a69d9c1e99a4e4144 to your computer and use it in GitHub Desktop.
Save mayinx/17c8a399dcad3a6a69d9c1e99a4e4144 to your computer and use it in GitHub Desktop.
Easy Ruby-Benchmarking
# 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