about summary refs log tree commit homepage
path: root/test/benchmark/request.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-03-10 18:44:34 -0700
committerEric Wong <normalperson@yhbt.net>2009-03-22 19:04:27 -0700
commit98ea5cca50b907e20d6357f425d7789bac1d1a47 (patch)
tree73e3823c0cd4f23f806ac392e66e12c3d77fc61c /test/benchmark/request.rb
parentca4265ea4d8bdeb9c569a50a05ee45e31f4b4269 (diff)
downloadunicorn-98ea5cca50b907e20d6357f425d7789bac1d1a47.tar.gz
dd.ru is a rackup file is intended as a dd(1)-like test for I/O
performance.

There are also individual request, response, and big_request
benchmarks for micro benchmarking some parts of Unicorn.

The rest of the benchmarks are gone: I am not interested in
performance comparisons (and pissing matches) with other web
servers (or their fanboys/girls).

I will _NEVER_ publically publish benchmarks comparing Unicorn
against other web servers.  I will only compare Unicorn against
other versions of Unicorn, possibly on different platforms.

Neutral third-parties are invited to publish their own
benchmarks (along with detailed procedures, version numbers and
other details) comparing Unicorn to other servers.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Diffstat (limited to 'test/benchmark/request.rb')
-rw-r--r--test/benchmark/request.rb47
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