Bug #2721
closedOpenSSL::Random.random_bytes(1) is very slow the first time on Windows
Description
=begin
This seems to be true across 1.8.6, 1.8.7 and even 1.9.1 compiled with either MSVC6 or mingw.
The first call to OpenSSL::Random.random_bytes for any number of bytes is very slow, proportional to something like the amount of code loaded already.
On my machine, the first call in a fresh irb session takes about 2 seconds.
Running something like this:
10000.times do |i|
eval("class SomeClass#{i}; end;")
end
increases the time for the first call to random_bytes to 5 seconds.
With a fresh Rails script/console, the first call takes about 30 seconds. Inside the first Rails request, it takes 80 seconds.
Calling the function as soon as possible allows me to spend only 2 seconds and not 80 later, but this seems like a very fixable thing.
=end