Skip to content

Instantly share code, notes, and snippets.

@paulohrpinheiro
Created April 4, 2017 14:15
Show Gist options
  • Save paulohrpinheiro/85a75c16be926aa534797de8beaff62f to your computer and use it in GitHub Desktop.
Save paulohrpinheiro/85a75c16be926aa534797de8beaff62f to your computer and use it in GitHub Desktop.
Quantos números aleatórios gero em 1 segundo? - Ruby
# frozen_string_literal: true
require 'timeout'
how_many = 0
rand_generator = Random.new
begin
Timeout.timeout(1) do
loop do
rand_generator.rand 100
how_many += 1
end
end
rescue Timeout::Error
puts how_many
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment