Skip to content

Instantly share code, notes, and snippets.

@Omochice
Created October 22, 2021 06:01
Show Gist options
  • Save Omochice/a09da508eb3c1661b0804c335f6fdc96 to your computer and use it in GitHub Desktop.
Save Omochice/a09da508eb3c1661b0804c335f6fdc96 to your computer and use it in GitHub Desktop.
require "benchmark"
Benchmark.bm do |x|
count = 10000
mappings = { "a" => [1, 1], "t" => [-1, 1], "g" => [-1, -1], "c" => [1, -1] }
x.report("hash.values.sample.size") do
_ = mappings.values.sample.size
end
x.report("hash.values[0].length ") do
_ = mappings.values[0].length
end
end
@Omochice
Copy link
Author

Omochice commented Oct 22, 2021

user system total real
hash.values.sample.size 0.000033 0.000009 0.000042 ( 0.000037)
hash.values[0].length 0.000003 0.000001 0.000004 ( 0.000003)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment