Net::HTTP.check_response very slow??

T

Tim Ferrell

I am working on something that uses Net::HTTP to obtain the final url
from a redirected url and, well, it seems really slow. I'm using ruby
1.8.6-p111 and have verified this behavior on OS X, Ubuntu Linux, and
Windows XP.

A sample app is attached and here were my results, comparing the pure
ruby approach to one shelling out to curl...

Tim@thinktank: tmp => time ./url_check.rb
http://ia340903.us.archive.org/0/it...kedown.451.sbeok.shnf/gd90-02-26d3t05_vbr.mp3

real 0m32.659s
user 0m4.423s
sys 0m3.168s

Tim@thinktank: tmp => time ./url_check.rb --use-curl
http://ia340903.us.archive.org/0/it...kedown.451.sbeok.shnf/gd90-02-26d3t05_vbr.mp3

real 0m0.754s
user 0m0.030s
sys 0m0.022s

I expected the pure ruby approach to be slower but these results seem
out of line just for a series of http response checks... Any ideas?

Cheers,
Tim

Attachments:
http://www.ruby-forum.com/attachment/1529/url_check.rb
 
J

Jeremy Hinegardner

I am working on something that uses Net::HTTP to obtain the final url
from a redirected url and, well, it seems really slow. I'm using ruby
1.8.6-p111 and have verified this behavior on OS X, Ubuntu Linux, and
Windows XP.

A sample app is attached and here were my results, comparing the pure
ruby approach to one shelling out to curl...

Tim@thinktank: tmp => time ./url_check.rb
http://ia340903.us.archive.org/0/it...kedown.451.sbeok.shnf/gd90-02-26d3t05_vbr.mp3

real 0m32.659s
user 0m4.423s
sys 0m3.168s

You are doing a full HTTP GET in this request and it is downloading the mp3.
Try:

response = Net::HTTP.start('ia340903.us.archive.org') do |http|
http.head('/0/items/gd90-02-26.sbd.shakedown.451.sbeok.shnf/gd90-02-26d3t05_vbr.mp3')
end
Tim@thinktank: tmp => time ./url_check.rb --use-curl
http://ia340903.us.archive.org/0/it...kedown.451.sbeok.shnf/gd90-02-26d3t05_vbr.mp3

real 0m0.754s
user 0m0.030s
sys 0m0.022s

You are using curl's -I option here which odes an HTTP HEAD and only gets the
headers of the response, and does retrieve the
I expected the pure ruby approach to be slower but these results seem
out of line just for a series of http response checks... Any ideas?

Cheers,
Tim

enjoy,

-jeremy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,198
Latest member
JaimieWan8

Latest Threads

Top