Skip to content

Instantly share code, notes, and snippets.

@cyx
Created March 21, 2010 18:22
Show Gist options
  • Save cyx/339473 to your computer and use it in GitHub Desktop.
Save cyx/339473 to your computer and use it in GitHub Desktop.
require 'open-uri'
require 'benchmark'
total = Benchmark.realtime {
threads = 30.times.map do
Thread.new {
gamers = Benchmark.realtime {
open("http://boughtstuff.com").read
}
puts "-----> Done in #{gamers}!"
}
end
threads.each { |t| t.join }
}
puts "-----> Finished everything in #{total}"
__END__
-----> Done in 7.59248805046082!
-----> Done in 8.3430540561676!
-----> Done in 8.47209692001343!
-----> Done in 8.5212128162384!
-----> Done in 10.3357660770416!
-----> Done in 10.8975551128387!
-----> Done in 12.5830090045929!
-----> Done in 15.0155138969421!
-----> Done in 15.2992680072784!
-----> Done in 15.5110559463501!
-----> Done in 16.305655002594!
-----> Done in 20.0016090869904!
-----> Done in 20.2180500030518!
-----> Done in 20.5008389949799!
-----> Done in 21.0006508827209!
-----> Done in 21.2516548633575!
-----> Done in 23.3948261737823!
-----> Done in 23.3900542259216!
-----> Done in 24.9772238731384!
-----> Done in 25.2382619380951!
-----> Done in 25.8209171295166!
-----> Done in 27.0780420303345!
-----> Done in 28.9907140731812!
-----> Done in 29.4281361103058!
-----> Done in 30.7136800289154!
-----> Done in 31.8364310264587!
-----> Done in 32.1602730751038!
-----> Done in 32.3921060562134!
-----> Done in 32.4077119827271!
-----> Done in 32.5992429256439!
-----> Finished everything in 32.6459259986877
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment