Created
January 13, 2012 01:01
Revisions
-
tjwallace created this gist
Jan 13, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ 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