macournoyer / thin-turbo

New and ultra-turbo-crazy-fast backend for Thin

This URL has Read+Write access

macournoyer (author)
Wed Jun 11 19:32:21 -0700 2008
commit  b708830bd819c5b733441b45a4ecb626a9da0d74
tree    b26aa27df2b16c37ca4e92735ae3cf1a658f32b9
parent  8217c704e02202e9a1bf2a92aaf6c0adce38835f
thin-turbo / benchmark / run
100755 38 lines (30 sloc) 1.027 kb
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
30
31
32
33
34
35
36
37
38
#!/usr/bin/env ruby
require File.dirname(__FILE__) + "/benchmarker"
require 'optparse'
 
MB = 1024 ** 2
CONCURRENCY_RANGE = [1, 10, 50]
WAIT_RANGE = [1, 2, 3]
FILE_RANGE = [1 * MB] #, 5 * MB , 10 * MB]
 
options = {
  :keep_alive => false,
}
range = nil
method = (ARGV[0] || :concurrency).to_sym
 
OptionParser.new do |opts|
  opts.banner = "Usage: #{$0} (concurrency|wait|upload|download) [options]"
 
  opts.on("-n NUM", "--requests", "Number of requests") { |n| options[:requests] = n }
  opts.on("-r EVAL", "--range", "Range used to run benchmark") { |r| range = eval("[#{r}]") }
  opts.on("-k", "--keep-alive", "Use persistent connections") { options[:keep_alive] = true }
  
  opts.on_tail("-h", "--help", "Show this message") { puts opts; exit }
end.parse!(ARGV)
 
unless range
  case method
  when :concurrency
    range = CONCURRENCY_RANGE
  when :wait
    range = WAIT_RANGE
  when :upload, :download
    range = FILE_RANGE
  end
end
 
puts Benchmarker.new(method, range, options).to_s(11)