Skip to content

Instantly share code, notes, and snippets.

Created February 18, 2009 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/66525 to your computer and use it in GitHub Desktop.
Save anonymous/66525 to your computer and use it in GitHub Desktop.
require 'benchmark'
require 'rubygems'
require 'rest_client'
Benchmark.bm(25) do |x|
etag = nil
x.report("(freshen view, fetch etag)") do
resp = RestClient.get "localhost:5984/gateway-development/_view/Image/all?include_docs=true&reduce=false"
etag = resp.headers[:etag]
end
x.report("couchdb") do
1.times do |i|
`curl "localhost:5984/gateway-development/_view/Image/all?include_docs=true&reduce=false" 2&> /dev/null`
end
end
x.report("couchdb+etag") do
1.times do |i|
`curl -H 'If-None-Match: \"#{etag}\"'"localhost:5984/gateway-development/_view/Image/all?include_docs=true&reduce=false" 2&> /dev/null`
end
end
x.report("merb") do
1.times do |i|
`curl "localhost:4000/images" 2&> /dev/null`
end
end
end
# user system total real
#1st request 0.270000 0.140000 0.410000 ( 1.265971)
#couchdb 0.000000 0.010000 0.080000 ( 1.192913)
#couchdb+etag 0.000000 0.000000 0.030000 ( 0.030326)
#merb 0.010000 0.010000 0.050000 ( 1.442723)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment