1 # This benchmark is the simplest test of the I/O facilities in
2 # unicorn. It is meant to return a fixed-sized blob to test
3 # the performance of things in Unicorn, _NOT_ the app.
5 # Adjusting this benchmark is done via the "bs" (byte size) and "count"
6 # environment variables. "count" designates the count of elements of
7 # "bs" length in the Rack response body. The defaults are bs=4096, count=1
8 # to return one 4096-byte chunk.
9 bs = ENV['bs'] ? ENV['bs'].to_i : 4096
10 count = ENV['count'] ? ENV['count'].to_i : 1
11 slice = (' ' * bs).freeze
12 body = (1..count).map { slice }.freeze
14 'Content-Length' => (bs * count).to_s.freeze,
15 'Content-Type' => 'text/plain'.freeze
17 response = [ 200, hdr, body ].freeze
18 run(lambda { |env| response })