Created
September 26, 2023 18:09
-
-
Save jjb/2d5ded544be8a2d09c3da192fd7c41cf to your computer and use it in GitHub Desktop.
benchmark ruby rand vs rand(100)
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/ips' | |
require "benchmark/memory" | |
Benchmark.ips do |x| | |
x.report("rand") do | |
rand | |
end | |
x.report("rand(100)") do | |
rand(100) | |
end | |
end | |
Benchmark.memory do |x| | |
x.report("rand") do | |
rand | |
end | |
x.report("rand(100)") do | |
rand(100) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment