Skip to content

Instantly share code, notes, and snippets.

@derencius
Created August 22, 2008 23:30
Show Gist options
  • Save derencius/6868 to your computer and use it in GitHub Desktop.
Save derencius/6868 to your computer and use it in GitHub Desktop.
A simple benchmark between open-uri and rio
# open-uri vs rio
require 'rubygems'
require 'open-uri'
require 'rio'
require 'benchmark'
n = 500
Benchmark.bm do |x|
x.report { for i in 1..n; open("http://localhost:4000/robots.txt?b#{i}").to_a; end }
x.report { for i in 1..n; rio("http://localhost:4000/robots.txt?a#{i}").to_a; end }
end
# user system total real
# 0.610000 0.310000 0.920000 ( 2.752151)
# 1.090000 0.350000 1.440000 ( 4.522792)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment