-
-
Save danmayer/6104806 to your computer and use it in GitHub Desktop.
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 characters
#!/usr/bin/env ruby | |
require 'rest_client' | |
require 'net/http' | |
require 'benchmark' | |
URL = 'https://www.livingsocial.com/deals/753290-tacos-and-margaritas-for-two-or-four' | |
time = Benchmark.realtime do | |
(1..100).each { | |
url = URI.parse(URL) | |
req = Net::HTTP::Get.new(url.path) | |
res = Net::HTTP.start(url.host, url.port, :use_ssl => url.scheme == 'https') {|http| http.request(req) } | |
} | |
end | |
printf("NET::HTTP => Time elapsed %0.3f seconds\n", "#{time}") | |
time = Benchmark.realtime do | |
(1..100).each { | |
RestClient.get(URL) | |
} | |
end | |
printf("RestClient => Time elapsed %0.3f seconds\n", "#{time}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah so looks like Adam Keys pointed out it likely is just rest-client follows redirects by default and Net::Http doesn't. Doug Ramsay confirmed that net http just immediately returns the 301