From 6096fc8d0c5e61a4342d5ccd0ff9df0213e8c062 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 14 Aug 2009 21:03:41 -0700 Subject: Drop the micro benchmarks It's not worth the effort to keep the internal API consistent between non-bugfix versions. --- test/benchmark/README | 5 ---- test/benchmark/big_request.rb | 44 ---------------------------------- test/benchmark/request.rb | 56 ------------------------------------------- test/benchmark/response.rb | 30 ----------------------- 4 files changed, 135 deletions(-) delete mode 100644 test/benchmark/big_request.rb delete mode 100644 test/benchmark/request.rb delete mode 100644 test/benchmark/response.rb (limited to 'test/benchmark') diff --git a/test/benchmark/README b/test/benchmark/README index b63b8a3..1d3cdd0 100644 --- a/test/benchmark/README +++ b/test/benchmark/README @@ -42,11 +42,6 @@ The benchmark client is usually httperf. Another gentle reminder: performance with slow networks/clients is NOT our problem. That is the job of nginx (or similar). -== request.rb, response.rb, big_request.rb - -These are micro-benchmarks designed to test internal components -of Unicorn. It assumes the internal Unicorn API is mostly stable. - == Contributors This directory is maintained independently in the "benchmark" branch diff --git a/test/benchmark/big_request.rb b/test/benchmark/big_request.rb deleted file mode 100644 index a250c62..0000000 --- a/test/benchmark/big_request.rb +++ /dev/null @@ -1,44 +0,0 @@ -require 'benchmark' -require 'tempfile' -require 'unicorn' -nr = ENV['nr'] ? ENV['nr'].to_i : 100 -bs = ENV['bs'] ? ENV['bs'].to_i : (1024 * 1024) -count = ENV['count'] ? ENV['count'].to_i : 4 -length = bs * count -slice = (' ' * bs).freeze - -big = Tempfile.new('') - -def big.unicorn_peeraddr # old versions of Unicorn used this - '127.0.0.1' -end - -big.syswrite( -"PUT /hello/world/puturl?abcd=efg&hi#anchor HTTP/1.0\r\n" \ -"Host: localhost\r\n" \ -"Accept: */*\r\n" \ -"Content-Length: #{length}\r\n" \ -"User-Agent: test-user-agent 0.1.0 (Mozilla compatible) 5.0 asdfadfasda\r\n" \ -"\r\n") -count.times { big.syswrite(slice) } -big.sysseek(0) -big.fsync - -include Unicorn -request = HttpRequest.new(Logger.new($stderr)) -unless request.respond_to?(:reset) - def request.reset - # no-op - end -end - -Benchmark.bmbm do |x| - x.report("big") do - for i in 1..nr - request.read(big) - request.reset - big.sysseek(0) - end - end -end - diff --git a/test/benchmark/request.rb b/test/benchmark/request.rb deleted file mode 100644 index fc7822c..0000000 --- a/test/benchmark/request.rb +++ /dev/null @@ -1,56 +0,0 @@ -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 - - alias readpartial sysread - - # old versions of Unicorn used this - 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)) -unless request.respond_to?(:reset) - def request.reset - # no-op - end -end - -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 diff --git a/test/benchmark/response.rb b/test/benchmark/response.rb deleted file mode 100644 index cb7397b..0000000 --- a/test/benchmark/response.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'benchmark' -require 'unicorn' - -class NullWriter - def syswrite(buf); buf.size; end - alias write syswrite - def close; end -end - -include Unicorn - -socket = NullWriter.new -bs = ENV['bs'] ? ENV['bs'].to_i : 4096 -count = ENV['count'] ? ENV['count'].to_i : 1 -slice = (' ' * bs).freeze -body = (1..count).map { slice }.freeze -hdr = { - 'Content-Length' => (bs * count).to_s.freeze, - 'Content-Type' => 'text/plain'.freeze -}.freeze -response = [ 200, hdr, body ].freeze - -nr = ENV['nr'] ? ENV['nr'].to_i : 100000 -Benchmark.bmbm do |x| - x.report do - for i in 1..nr - HttpResponse.write(socket.dup, response) - end - end -end -- cgit v1.2.3-24-ge0c7