Created
January 13, 2012 01:01
-
-
Save tjwallace/1604082 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' | |
require 'net/http' | |
require 'uri' | |
def network_read(uri) | |
Net::HTTP.get_response uri | |
end | |
n = 100 | |
uri = URI('http://google.com/') | |
Benchmark.bm(5) do |x| | |
x.report('loop ') { n.times { network_read(uri) } } | |
x.report('threads') { | |
n.times.map { | |
Thread.new { network_read(uri) } | |
}.map(&:join) | |
} | |
end |
cpb
commented
Jan 13, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment