diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-03-22 20:58:11 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-03-22 20:58:11 -0700 |
commit | f4503b0eb9dd73296988021f355f3d28959975e5 (patch) | |
tree | 5be11934e0ac81d2331d4d5b60693ae77dc94d91 /test/benchmark/request.rb | |
parent | 78668173ab0e78c5c94fe23b916a81822c24bf9c (diff) | |
parent | 018f827ebdc1668d2262ef1337386f896379e0f6 (diff) | |
download | unicorn-f4503b0eb9dd73296988021f355f3d28959975e5.tar.gz |
* commit 'origin/benchmark': benchmark: header values must be strings All new benchmarks, old ones removed
Diffstat (limited to 'test/benchmark/request.rb')
-rw-r--r-- | test/benchmark/request.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test/benchmark/request.rb b/test/benchmark/request.rb new file mode 100644 index 0000000..67266cb --- /dev/null +++ b/test/benchmark/request.rb @@ -0,0 +1,47 @@ +require 'benchmark' +require 'unicorn' +nr = ENV['nr'] ? ENV['nr'].to_i : 100000 + +class TestClient + def initialize(response) + @response = (response.join("\r\n") << "\r\n\r\n").freeze + end + def sysread(len, buf) + buf.replace(@response) + end + + def unicorn_peeraddr + '127.0.0.1' + end +end + +small = TestClient.new([ + 'GET / HTTP/1.0', + 'Host: localhost', + 'Accept: */*', + 'User-Agent: test-user-agent 0.1.0' +]) + +medium = TestClient.new([ + 'GET /hello/world/geturl?abcd=efg&hi#anchor HTTP/1.0', + 'Host: localhost', + 'Accept: */*', + 'User-Agent: test-user-agent 0.1.0 (Mozilla compatible) 5.0 asdfadfasda' +]) + +include Unicorn +request = HttpRequest.new(Logger.new($stderr)) +Benchmark.bmbm do |x| + x.report("small") do + for i in 1..nr + request.read(small) + request.reset + end + end + x.report("medium") do + for i in 1..nr + request.read(medium) + request.reset + end + end +end |