Last active
March 16, 2020 12:34
-
-
Save foxweb/3dfacf3ba0ca2a871abc4147b2020245 to your computer and use it in GitHub Desktop.
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
require 'benchmark' | |
n = 100_000 | |
abc = ('A'..'Z').to_a | |
Benchmark.bm do |x| | |
x.report { n.times { rand(65..90).chr } } | |
x.report { n.times { rand('A'.ord..'Z'.ord).chr } } | |
x.report { n.times { ('A'..'Z').to_a.sample } } | |
x.report { n.times { abc.sample } } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment