From: Elliot Temple Date: 2006-07-05T04:24:39+09:00 Subject: Re: open-uri speed On Jul 4, 2006, at 2:26 AM, Carlos wrote: > Elliot Temple wrote: >> I just discovered this. Lots of people already know, I'm sure, >> but maybe some don't. >> # net/http ran in: 128.734298 seconds. >> # open-uri ran in: 268.869359 seconds. >> require "net/http" >> require "open-uri" >> def timing(name) >> start_time = Time.now >> yield >> end_time = Time.now >> puts "#{name} ran in: #{end_time - start_time} seconds." >> end >> n = 1_000 >> timing("net/http") {Net::HTTP.start("www.pythonchallenge.com") do | >> http| >> n.times do |i| >> r = http.get("/pc/def/linkedlist.php") >> end >> end} > > Doesn't this version open the connection only once and then reuses > it for all the requests? I don't know. But I started testing with n=1 and an outer loop, so the Net::HTTP.start is repeated, and net/http is still winning (by more than URI parsing accounts for). I will run some longer tests later to get more accurate data (and intermix doing it each way to minimise the effect of random net traffic fluctuations). I will use a static page as Robert suggested. -- Elliot Temple http://www.curi.us/blog/