Skip to content

Instantly share code, notes, and snippets.

@terrbear
Created June 19, 2009 19:29
Show Gist options
  • Select an option

  • Save terrbear/132809 to your computer and use it in GitHub Desktop.

Select an option

Save terrbear/132809 to your computer and use it in GitHub Desktop.
CURB!
irb(main):010:0> req = Net::HTTP.new("google.com", 80)
=> #<Net::HTTP google.com:80 open=false>
irb(main):011:0> curl = Curl::Easy.perform("http://www.google.com")
=> #<Curl::Easy:0x876ba58>
irb(main):012:0> Benchmark.bm do |x|
irb(main):013:1* x.report("net/http"){20.times{req.start{|http| http.get("/")}}}
irb(main):014:1> x.report("curb"){20.times{curl.perform}}
irb(main):015:1> end
user system total real
net/http 0.010000 0.000000 0.010000 ( 28.866806)
curb 0.000000 0.010000 0.010000 ( 1.625923)
=> true
-----
the test:
req = Net::HTTP.new("google.com", 80)
Benchmark.bm do |x|
x.report {100.times{req.start{|http| http.get("/")}}}
end
both benchmarks are GETting google.com 100 times
ded2 (portal)
>> Benchmark.bmbm do |x|
?> x.report {100.times{req.start{|http| http.get("/")}}}
>> end
Rehearsal ------------------------------------
0.130000 0.010000 0.140000 ( 10.912258)
--------------------------- total: 0.140000sec
user system total real
0.050000 0.010000 0.060000 ( 10.517465)
staging2
>> Benchmark.bmbm do |x|
?> x.report {100.times{req.start{|http| http.get("/")}}}
>> end
Rehearsal ------------------------------------
0.050000 0.020000 0.070000 ( 91.207375)
--------------------------- total: 0.070000sec
user system total real
0.060000 0.020000 0.080000 ( 94.495068)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment