I can't speak to the speed of any curl library, but I can cite my
recent experience building a crawler like app. I'm using non-blocking
sockets and therefore can't utilize Net::HTTP and am hand-coding HTTP
directly. Under OS X I found a lot of latency (around 100ms) for both
IPSocket.getaddress() and Socket.sockaddr_in(). Under Linux packing
sockaddr seems to incur a negligible cost. Under OS X I pack the
sockaddr manually (yeah, it's gross). To mitigate the host lookup
cost I maintain a cache (Hashmap) of host => IP. (At least under OS
X, even resolving localhost takes 100ms, even on repeat calls.)
The point being that I would assume that Net::HTTP inherits the costs
of these two calls. Which would explain at least some of the
connection slowness. As for download speed, I could only make
guesses, and they'd be pretty uneducated. I would suspect C has
better I/O performance than Ruby, so a native library would probably
be faster.
Corey
On Aug 22, 2006, at 8:17 PM, Ben Johnson wrote:
> I've found a couple of packages that claim to integrate the curl
> library
> into ruby. Which one is the standard library?
>
> Also the reason I am asking is because I did some tests and came to
> find
> out that curl is quite a bit faster than the HTTP library. Is this
> true,
> maybe my tests were distorted, but curl seemed to be quite a bit
> faster
> in initializing the connection and downloading.
>
> Would it be smart of me to switch from Net::HTTP to curl? Because a
> tenth of a second is precious in my application.
>
> Thanks for your help.
>
> --
> Posted via http://www.ruby-forum.com/.
>