unicorn.git  about / heads / tags
Rack HTTP server for Unix and fast clients
blob 0ff0ac2345d66c66b72f34ca52a6302755bf942f 607 bytes (raw)
$ git show v0.4.1:test/benchmark/response.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 
require 'benchmark'
require 'unicorn'

class NullWriter
  def syswrite(buf); buf.size; end
  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

git clone https://yhbt.net/unicorn.git