I get this kind of results with the next benchmark, by retrieving data from Google.
Warming up --------------------------------------
OpenURI 3.000 i/100ms
Net::HTTP 3.000 i/100ms
curb 3.000 i/100ms
rest_client 3.000 i/100ms
Calculating -------------------------------------
OpenURI 34.848 (±11.5%) i/s - 687.000 in 20.013469s
Net::HTTP 35.433 (±14.1%) i/s - 594.000 in 20.006947s
curb 31.612 (±19.0%) i/s - 465.000 in 20.021108s
rest_client 34.331 (±11.7%) i/s - 675.000 in 20.044486s
Comparison:
Net::HTTP: 35.4 i/s
OpenURI: 34.8 i/s - same-ish: difference falls within error
rest_client: 34.3 i/s - same-ish: difference falls within error
curb: 31.6 i/s - same-ish: difference falls within error
And here is a source code of the benchmark
require 'benchmark/ips'
require 'open-uri'
require 'net/http'
require 'curb'
require 'rest-client'
google_uri = URI('http://www.google.com/')
google_uri_string = google_uri.to_s
Benchmark.ips do |x|
x.config(time: 20, warmup: 10)
x.report('OpenURI') { open(google_uri_string) }
x.report('Net::HTTP') { Net::HTTP.get(google_uri) }
x.report('curb') { Curl.get(google_uri_string) }
x.report('rest_client') { RestClient.get(google_uri_string) }
x.compare!
end
ENVIRONMENT:
- AWS EC2 server
- Ruby version - 2.5.1p57
- Gems: curb-0.9.6, rest-client-2.0.2, benchmark-ips-2.7.2
NOTES:
Don't forget to install gems before running this benchmark
gem install curb rest-client benchmark-ips
To get more accurate results run in a stable network environment, like production servers