From: Mick Jagger Date: 2013-06-04T05:05:35+09:00 Subject: Re: Ruby extremely slow compared to PHP Tamara Temple wrote in post #1111074: > So, basically, curl is getting a lot less data than Net::HTTP is > getting. I haven't delved into why this is so, but these are interesting > stats: > > > This is for the ruby version: > > Total fetch time: 28 seconds. > Total fetch size: 1954452 bytes. > > real 0m28.175s > user 0m0.224s > sys 0m0.020s > > > > And this is for the PHP version: > > Total fetch time: 18 seconds. > Total fetch bytes: 224888 > > real 0m18.077s > user 0m0.048s > sys 0m0.028s > > Look at the difference in the amount of data transferred. Net::HTTP is > pulling in *eight times* as much data as curl is. Why is this the case? > That might be worth more investigation... > > But also look at the differences shown; the algorithms themselves take > nearly no time, which is to be expected. > > At any rate (haha, p.i.), you definitely can not make the case that ruby > is slower than php from this, as all the time is spent in transfer, not > execution. > > P.S. "Mick": I had to clean up your PHP script a bit as it was tossing > warnings and notices all over. Your ruby script, OTOH, was flawless. I > did change a couple things in order to get the totals, but not the > fundamental algorithms. Thanks for your answer! I think the PHP warnings are because I have disabled them, but think it would be a good practice to turn them on again haha. As you could have seen, in my PHP script, the cURL handle is not closed, what improves a lot the request speed as I have tested. May be because of this the Ruby script is slower. So the "slowness" of the script is because of how connections are handled I guess. Regards. -- Posted via http://www.ruby-forum.com/.