unicorn 0.2.3 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/.document +1 -1
  2. data/.gitignore +1 -0
  3. data/CHANGELOG +1 -0
  4. data/DESIGN +4 -0
  5. data/GNUmakefile +30 -6
  6. data/Manifest +62 -3
  7. data/README +52 -42
  8. data/SIGNALS +17 -17
  9. data/TODO +27 -5
  10. data/bin/unicorn +15 -13
  11. data/bin/unicorn_rails +59 -22
  12. data/ext/unicorn/http11/http11.c +25 -104
  13. data/ext/unicorn/http11/http11_parser.c +24 -23
  14. data/ext/unicorn/http11/http11_parser.h +1 -3
  15. data/ext/unicorn/http11/http11_parser.rl +2 -1
  16. data/lib/unicorn.rb +58 -44
  17. data/lib/unicorn/app/old_rails.rb +23 -0
  18. data/lib/unicorn/app/old_rails/static.rb +58 -0
  19. data/lib/unicorn/cgi_wrapper.rb +151 -0
  20. data/lib/unicorn/configurator.rb +71 -31
  21. data/lib/unicorn/const.rb +9 -34
  22. data/lib/unicorn/http_request.rb +63 -66
  23. data/lib/unicorn/http_response.rb +6 -1
  24. data/lib/unicorn/socket.rb +15 -2
  25. data/test/benchmark/README +55 -0
  26. data/test/benchmark/big_request.rb +35 -0
  27. data/test/benchmark/dd.ru +18 -0
  28. data/test/benchmark/request.rb +47 -0
  29. data/test/benchmark/response.rb +29 -0
  30. data/test/exec/test_exec.rb +41 -157
  31. data/test/rails/app-1.2.3/.gitignore +2 -0
  32. data/test/rails/app-1.2.3/app/controllers/application.rb +4 -0
  33. data/test/rails/app-1.2.3/app/controllers/foo_controller.rb +34 -0
  34. data/test/rails/app-1.2.3/app/helpers/application_helper.rb +2 -0
  35. data/test/rails/app-1.2.3/config/boot.rb +9 -0
  36. data/test/rails/app-1.2.3/config/database.yml +12 -0
  37. data/test/rails/app-1.2.3/config/environment.rb +10 -0
  38. data/test/rails/app-1.2.3/config/environments/development.rb +7 -0
  39. data/test/rails/app-1.2.3/config/environments/production.rb +3 -0
  40. data/test/rails/app-1.2.3/config/routes.rb +4 -0
  41. data/test/rails/app-1.2.3/db/.gitignore +0 -0
  42. data/test/rails/app-1.2.3/public/404.html +1 -0
  43. data/test/rails/app-1.2.3/public/500.html +1 -0
  44. data/test/rails/app-2.0.2/.gitignore +2 -0
  45. data/test/rails/app-2.0.2/app/controllers/application.rb +2 -0
  46. data/test/rails/app-2.0.2/app/controllers/foo_controller.rb +34 -0
  47. data/test/rails/app-2.0.2/app/helpers/application_helper.rb +2 -0
  48. data/test/rails/app-2.0.2/config/boot.rb +9 -0
  49. data/test/rails/app-2.0.2/config/database.yml +12 -0
  50. data/test/rails/app-2.0.2/config/environment.rb +14 -0
  51. data/test/rails/app-2.0.2/config/environments/development.rb +6 -0
  52. data/test/rails/app-2.0.2/config/environments/production.rb +3 -0
  53. data/test/rails/app-2.0.2/config/routes.rb +4 -0
  54. data/test/rails/app-2.0.2/db/.gitignore +0 -0
  55. data/test/rails/app-2.0.2/public/404.html +1 -0
  56. data/test/rails/app-2.0.2/public/500.html +1 -0
  57. data/test/rails/app-2.2.2/.gitignore +2 -0
  58. data/test/rails/app-2.2.2/app/controllers/application.rb +2 -0
  59. data/test/rails/app-2.2.2/app/controllers/foo_controller.rb +34 -0
  60. data/test/rails/app-2.2.2/app/helpers/application_helper.rb +2 -0
  61. data/test/rails/app-2.2.2/config/boot.rb +109 -0
  62. data/test/rails/app-2.2.2/config/database.yml +12 -0
  63. data/test/rails/app-2.2.2/config/environment.rb +14 -0
  64. data/test/rails/app-2.2.2/config/environments/development.rb +5 -0
  65. data/test/rails/app-2.2.2/config/environments/production.rb +3 -0
  66. data/test/rails/app-2.2.2/config/routes.rb +4 -0
  67. data/test/rails/app-2.2.2/db/.gitignore +0 -0
  68. data/test/rails/app-2.2.2/public/404.html +1 -0
  69. data/test/rails/app-2.2.2/public/500.html +1 -0
  70. data/test/rails/app-2.3.2.1/.gitignore +2 -0
  71. data/test/rails/app-2.3.2.1/app/controllers/application_controller.rb +3 -0
  72. data/test/rails/app-2.3.2.1/app/controllers/foo_controller.rb +34 -0
  73. data/test/rails/app-2.3.2.1/app/helpers/application_helper.rb +2 -0
  74. data/test/rails/app-2.3.2.1/config/boot.rb +107 -0
  75. data/test/rails/app-2.3.2.1/config/database.yml +12 -0
  76. data/test/rails/app-2.3.2.1/config/environment.rb +14 -0
  77. data/test/rails/app-2.3.2.1/config/environments/development.rb +5 -0
  78. data/test/rails/app-2.3.2.1/config/environments/production.rb +4 -0
  79. data/test/rails/app-2.3.2.1/config/routes.rb +4 -0
  80. data/test/rails/app-2.3.2.1/db/.gitignore +0 -0
  81. data/test/rails/app-2.3.2.1/public/404.html +1 -0
  82. data/test/rails/app-2.3.2.1/public/500.html +1 -0
  83. data/test/rails/test_rails.rb +243 -0
  84. data/test/test_helper.rb +149 -2
  85. data/test/unit/test_configurator.rb +46 -0
  86. data/test/unit/test_http_parser.rb +77 -36
  87. data/test/unit/test_request.rb +2 -0
  88. data/test/unit/test_response.rb +20 -4
  89. data/test/unit/test_server.rb +30 -1
  90. data/test/unit/test_socket_helper.rb +159 -0
  91. data/unicorn.gemspec +5 -5
  92. metadata +68 -5
  93. data/test/benchmark/previous.rb +0 -11
  94. data/test/benchmark/simple.rb +0 -11
  95. data/test/benchmark/utils.rb +0 -82
@@ -2,17 +2,17 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{unicorn}
5
- s.version = "0.2.3"
5
+ s.version = "0.4.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Eric Wong"]
9
- s.date = %q{2009-03-25}
9
+ s.date = %q{2009-04-01}
10
10
  s.description = %q{A small fast HTTP library and server for Rack applications.}
11
11
  s.email = %q{normalperson@yhbt.net}
12
12
  s.executables = ["unicorn", "unicorn_rails"]
13
13
  s.extensions = ["ext/unicorn/http11/extconf.rb"]
14
- s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "TODO", "bin/unicorn", "bin/unicorn_rails", "ext/unicorn/http11/ext_help.h", "ext/unicorn/http11/extconf.rb", "ext/unicorn/http11/http11.c", "ext/unicorn/http11/http11_parser.c", "ext/unicorn/http11/http11_parser.h", "ext/unicorn/http11/http11_parser.rl", "ext/unicorn/http11/http11_parser_common.rl", "lib/unicorn.rb", "lib/unicorn/app/exec_cgi.rb", "lib/unicorn/configurator.rb", "lib/unicorn/const.rb", "lib/unicorn/http_request.rb", "lib/unicorn/http_response.rb", "lib/unicorn/launcher.rb", "lib/unicorn/socket.rb", "lib/unicorn/util.rb"]
15
- s.files = [".document", ".gitignore", "CHANGELOG", "CONTRIBUTORS", "DESIGN", "GNUmakefile", "LICENSE", "Manifest", "README", "Rakefile", "SIGNALS", "TODO", "bin/unicorn", "bin/unicorn_rails", "ext/unicorn/http11/ext_help.h", "ext/unicorn/http11/extconf.rb", "ext/unicorn/http11/http11.c", "ext/unicorn/http11/http11_parser.c", "ext/unicorn/http11/http11_parser.h", "ext/unicorn/http11/http11_parser.rl", "ext/unicorn/http11/http11_parser_common.rl", "lib/unicorn.rb", "lib/unicorn/app/exec_cgi.rb", "lib/unicorn/configurator.rb", "lib/unicorn/const.rb", "lib/unicorn/http_request.rb", "lib/unicorn/http_response.rb", "lib/unicorn/launcher.rb", "lib/unicorn/socket.rb", "lib/unicorn/util.rb", "setup.rb", "test/aggregate.rb", "test/benchmark/previous.rb", "test/benchmark/simple.rb", "test/benchmark/utils.rb", "test/exec/README", "test/exec/test_exec.rb", "test/test_helper.rb", "test/tools/trickletest.rb", "test/unit/test_configurator.rb", "test/unit/test_http_parser.rb", "test/unit/test_request.rb", "test/unit/test_response.rb", "test/unit/test_server.rb", "test/unit/test_upload.rb", "unicorn.gemspec"]
14
+ s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "TODO", "bin/unicorn", "bin/unicorn_rails", "ext/unicorn/http11/ext_help.h", "ext/unicorn/http11/extconf.rb", "ext/unicorn/http11/http11.c", "ext/unicorn/http11/http11_parser.c", "ext/unicorn/http11/http11_parser.h", "ext/unicorn/http11/http11_parser.rl", "ext/unicorn/http11/http11_parser_common.rl", "lib/unicorn.rb", "lib/unicorn/app/exec_cgi.rb", "lib/unicorn/app/old_rails.rb", "lib/unicorn/app/old_rails/static.rb", "lib/unicorn/cgi_wrapper.rb", "lib/unicorn/configurator.rb", "lib/unicorn/const.rb", "lib/unicorn/http_request.rb", "lib/unicorn/http_response.rb", "lib/unicorn/launcher.rb", "lib/unicorn/socket.rb", "lib/unicorn/util.rb"]
15
+ s.files = [".document", ".gitignore", "CHANGELOG", "CONTRIBUTORS", "DESIGN", "GNUmakefile", "LICENSE", "Manifest", "README", "Rakefile", "SIGNALS", "TODO", "bin/unicorn", "bin/unicorn_rails", "ext/unicorn/http11/ext_help.h", "ext/unicorn/http11/extconf.rb", "ext/unicorn/http11/http11.c", "ext/unicorn/http11/http11_parser.c", "ext/unicorn/http11/http11_parser.h", "ext/unicorn/http11/http11_parser.rl", "ext/unicorn/http11/http11_parser_common.rl", "lib/unicorn.rb", "lib/unicorn/app/exec_cgi.rb", "lib/unicorn/app/old_rails.rb", "lib/unicorn/app/old_rails/static.rb", "lib/unicorn/cgi_wrapper.rb", "lib/unicorn/configurator.rb", "lib/unicorn/const.rb", "lib/unicorn/http_request.rb", "lib/unicorn/http_response.rb", "lib/unicorn/launcher.rb", "lib/unicorn/socket.rb", "lib/unicorn/util.rb", "setup.rb", "test/aggregate.rb", "test/benchmark/README", "test/benchmark/big_request.rb", "test/benchmark/dd.ru", "test/benchmark/request.rb", "test/benchmark/response.rb", "test/exec/README", "test/exec/test_exec.rb", "test/rails/app-1.2.3/.gitignore", "test/rails/app-1.2.3/app/controllers/application.rb", "test/rails/app-1.2.3/app/controllers/foo_controller.rb", "test/rails/app-1.2.3/app/helpers/application_helper.rb", "test/rails/app-1.2.3/config/boot.rb", "test/rails/app-1.2.3/config/database.yml", "test/rails/app-1.2.3/config/environment.rb", "test/rails/app-1.2.3/config/environments/development.rb", "test/rails/app-1.2.3/config/environments/production.rb", "test/rails/app-1.2.3/config/routes.rb", "test/rails/app-1.2.3/db/.gitignore", "test/rails/app-1.2.3/public/404.html", "test/rails/app-1.2.3/public/500.html", "test/rails/app-2.0.2/.gitignore", "test/rails/app-2.0.2/app/controllers/application.rb", "test/rails/app-2.0.2/app/controllers/foo_controller.rb", "test/rails/app-2.0.2/app/helpers/application_helper.rb", "test/rails/app-2.0.2/config/boot.rb", "test/rails/app-2.0.2/config/database.yml", "test/rails/app-2.0.2/config/environment.rb", "test/rails/app-2.0.2/config/environments/development.rb", "test/rails/app-2.0.2/config/environments/production.rb", "test/rails/app-2.0.2/config/routes.rb", "test/rails/app-2.0.2/db/.gitignore", "test/rails/app-2.0.2/public/404.html", "test/rails/app-2.0.2/public/500.html", "test/rails/app-2.2.2/.gitignore", "test/rails/app-2.2.2/app/controllers/application.rb", "test/rails/app-2.2.2/app/controllers/foo_controller.rb", "test/rails/app-2.2.2/app/helpers/application_helper.rb", "test/rails/app-2.2.2/config/boot.rb", "test/rails/app-2.2.2/config/database.yml", "test/rails/app-2.2.2/config/environment.rb", "test/rails/app-2.2.2/config/environments/development.rb", "test/rails/app-2.2.2/config/environments/production.rb", "test/rails/app-2.2.2/config/routes.rb", "test/rails/app-2.2.2/db/.gitignore", "test/rails/app-2.2.2/public/404.html", "test/rails/app-2.2.2/public/500.html", "test/rails/app-2.3.2.1/.gitignore", "test/rails/app-2.3.2.1/app/controllers/application_controller.rb", "test/rails/app-2.3.2.1/app/controllers/foo_controller.rb", "test/rails/app-2.3.2.1/app/helpers/application_helper.rb", "test/rails/app-2.3.2.1/config/boot.rb", "test/rails/app-2.3.2.1/config/database.yml", "test/rails/app-2.3.2.1/config/environment.rb", "test/rails/app-2.3.2.1/config/environments/development.rb", "test/rails/app-2.3.2.1/config/environments/production.rb", "test/rails/app-2.3.2.1/config/routes.rb", "test/rails/app-2.3.2.1/db/.gitignore", "test/rails/app-2.3.2.1/public/404.html", "test/rails/app-2.3.2.1/public/500.html", "test/rails/test_rails.rb", "test/test_helper.rb", "test/tools/trickletest.rb", "test/unit/test_configurator.rb", "test/unit/test_http_parser.rb", "test/unit/test_request.rb", "test/unit/test_response.rb", "test/unit/test_server.rb", "test/unit/test_socket_helper.rb", "test/unit/test_upload.rb", "unicorn.gemspec"]
16
16
  s.has_rdoc = true
17
17
  s.homepage = %q{http://unicorn.bogomips.org}
18
18
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Unicorn", "--main", "README"]
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.rubyforge_project = %q{unicorn}
21
21
  s.rubygems_version = %q{1.3.1}
22
22
  s.summary = %q{A small fast HTTP library and server for Rack applications.}
23
- s.test_files = ["test/unit/test_configurator.rb", "test/unit/test_response.rb", "test/unit/test_request.rb", "test/unit/test_upload.rb", "test/unit/test_http_parser.rb", "test/unit/test_server.rb"]
23
+ s.test_files = ["test/unit/test_configurator.rb", "test/unit/test_response.rb", "test/unit/test_request.rb", "test/unit/test_upload.rb", "test/unit/test_http_parser.rb", "test/unit/test_socket_helper.rb", "test/unit/test_server.rb"]
24
24
 
25
25
  if s.respond_to? :specification_version then
26
26
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unicorn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Wong
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-25 00:00:00 -07:00
12
+ date: 2009-04-01 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -36,6 +36,9 @@ extra_rdoc_files:
36
36
  - ext/unicorn/http11/http11_parser_common.rl
37
37
  - lib/unicorn.rb
38
38
  - lib/unicorn/app/exec_cgi.rb
39
+ - lib/unicorn/app/old_rails.rb
40
+ - lib/unicorn/app/old_rails/static.rb
41
+ - lib/unicorn/cgi_wrapper.rb
39
42
  - lib/unicorn/configurator.rb
40
43
  - lib/unicorn/const.rb
41
44
  - lib/unicorn/http_request.rb
@@ -67,6 +70,9 @@ files:
67
70
  - ext/unicorn/http11/http11_parser_common.rl
68
71
  - lib/unicorn.rb
69
72
  - lib/unicorn/app/exec_cgi.rb
73
+ - lib/unicorn/app/old_rails.rb
74
+ - lib/unicorn/app/old_rails/static.rb
75
+ - lib/unicorn/cgi_wrapper.rb
70
76
  - lib/unicorn/configurator.rb
71
77
  - lib/unicorn/const.rb
72
78
  - lib/unicorn/http_request.rb
@@ -76,11 +82,66 @@ files:
76
82
  - lib/unicorn/util.rb
77
83
  - setup.rb
78
84
  - test/aggregate.rb
79
- - test/benchmark/previous.rb
80
- - test/benchmark/simple.rb
81
- - test/benchmark/utils.rb
85
+ - test/benchmark/README
86
+ - test/benchmark/big_request.rb
87
+ - test/benchmark/dd.ru
88
+ - test/benchmark/request.rb
89
+ - test/benchmark/response.rb
82
90
  - test/exec/README
83
91
  - test/exec/test_exec.rb
92
+ - test/rails/app-1.2.3/.gitignore
93
+ - test/rails/app-1.2.3/app/controllers/application.rb
94
+ - test/rails/app-1.2.3/app/controllers/foo_controller.rb
95
+ - test/rails/app-1.2.3/app/helpers/application_helper.rb
96
+ - test/rails/app-1.2.3/config/boot.rb
97
+ - test/rails/app-1.2.3/config/database.yml
98
+ - test/rails/app-1.2.3/config/environment.rb
99
+ - test/rails/app-1.2.3/config/environments/development.rb
100
+ - test/rails/app-1.2.3/config/environments/production.rb
101
+ - test/rails/app-1.2.3/config/routes.rb
102
+ - test/rails/app-1.2.3/db/.gitignore
103
+ - test/rails/app-1.2.3/public/404.html
104
+ - test/rails/app-1.2.3/public/500.html
105
+ - test/rails/app-2.0.2/.gitignore
106
+ - test/rails/app-2.0.2/app/controllers/application.rb
107
+ - test/rails/app-2.0.2/app/controllers/foo_controller.rb
108
+ - test/rails/app-2.0.2/app/helpers/application_helper.rb
109
+ - test/rails/app-2.0.2/config/boot.rb
110
+ - test/rails/app-2.0.2/config/database.yml
111
+ - test/rails/app-2.0.2/config/environment.rb
112
+ - test/rails/app-2.0.2/config/environments/development.rb
113
+ - test/rails/app-2.0.2/config/environments/production.rb
114
+ - test/rails/app-2.0.2/config/routes.rb
115
+ - test/rails/app-2.0.2/db/.gitignore
116
+ - test/rails/app-2.0.2/public/404.html
117
+ - test/rails/app-2.0.2/public/500.html
118
+ - test/rails/app-2.2.2/.gitignore
119
+ - test/rails/app-2.2.2/app/controllers/application.rb
120
+ - test/rails/app-2.2.2/app/controllers/foo_controller.rb
121
+ - test/rails/app-2.2.2/app/helpers/application_helper.rb
122
+ - test/rails/app-2.2.2/config/boot.rb
123
+ - test/rails/app-2.2.2/config/database.yml
124
+ - test/rails/app-2.2.2/config/environment.rb
125
+ - test/rails/app-2.2.2/config/environments/development.rb
126
+ - test/rails/app-2.2.2/config/environments/production.rb
127
+ - test/rails/app-2.2.2/config/routes.rb
128
+ - test/rails/app-2.2.2/db/.gitignore
129
+ - test/rails/app-2.2.2/public/404.html
130
+ - test/rails/app-2.2.2/public/500.html
131
+ - test/rails/app-2.3.2.1/.gitignore
132
+ - test/rails/app-2.3.2.1/app/controllers/application_controller.rb
133
+ - test/rails/app-2.3.2.1/app/controllers/foo_controller.rb
134
+ - test/rails/app-2.3.2.1/app/helpers/application_helper.rb
135
+ - test/rails/app-2.3.2.1/config/boot.rb
136
+ - test/rails/app-2.3.2.1/config/database.yml
137
+ - test/rails/app-2.3.2.1/config/environment.rb
138
+ - test/rails/app-2.3.2.1/config/environments/development.rb
139
+ - test/rails/app-2.3.2.1/config/environments/production.rb
140
+ - test/rails/app-2.3.2.1/config/routes.rb
141
+ - test/rails/app-2.3.2.1/db/.gitignore
142
+ - test/rails/app-2.3.2.1/public/404.html
143
+ - test/rails/app-2.3.2.1/public/500.html
144
+ - test/rails/test_rails.rb
84
145
  - test/test_helper.rb
85
146
  - test/tools/trickletest.rb
86
147
  - test/unit/test_configurator.rb
@@ -88,6 +149,7 @@ files:
88
149
  - test/unit/test_request.rb
89
150
  - test/unit/test_response.rb
90
151
  - test/unit/test_server.rb
152
+ - test/unit/test_socket_helper.rb
91
153
  - test/unit/test_upload.rb
92
154
  - unicorn.gemspec
93
155
  has_rdoc: true
@@ -128,4 +190,5 @@ test_files:
128
190
  - test/unit/test_request.rb
129
191
  - test/unit/test_upload.rb
130
192
  - test/unit/test_http_parser.rb
193
+ - test/unit/test_socket_helper.rb
131
194
  - test/unit/test_server.rb
@@ -1,11 +0,0 @@
1
- # Benchmark to compare Mongrel performance against
2
- # previous Mongrel version (the one installed as a gem).
3
- #
4
- # Run with:
5
- #
6
- # ruby previous.rb [num of request]
7
- #
8
-
9
- require File.dirname(__FILE__) + '/utils'
10
-
11
- benchmark "print", %w(current gem), 1000, [1, 10, 100]
@@ -1,11 +0,0 @@
1
- #
2
- # Simple benchmark to compare Mongrel performance against
3
- # other webservers supported by Rack.
4
- #
5
-
6
- require File.dirname(__FILE__) + '/utils'
7
-
8
- libs = %w(current gem WEBrick EMongrel Thin)
9
- libs = ARGV if ARGV.any?
10
-
11
- benchmark "print", libs, 1000, [1, 10, 100]
@@ -1,82 +0,0 @@
1
-
2
- require 'rubygems'
3
- require 'rack'
4
- require 'rack/lobster'
5
-
6
- def run(handler_name, n=1000, c=1)
7
- port = 7000
8
-
9
- server = fork do
10
- [STDOUT, STDERR].each { |o| o.reopen "/dev/null" }
11
-
12
- case handler_name
13
- when 'EMongrel'
14
- require 'swiftcore/evented_mongrel'
15
- handler_name = 'Mongrel'
16
-
17
- when 'Thin'
18
- require 'thin'
19
- hander_name = 'Thin'
20
-
21
- when 'gem' # Load the current Mongrel gem
22
- require 'mongrel'
23
- handler_name = 'Mongrel'
24
-
25
- when 'current' # Load the current Mongrel version under /lib
26
- require File.dirname(__FILE__) + '/../lib/mongrel'
27
- handler_name = 'Mongrel'
28
-
29
- end
30
-
31
- app = Rack::Lobster.new
32
-
33
- handler = Rack::Handler.const_get(handler_name)
34
- handler.run app, :Host => '0.0.0.0', :Port => port
35
- end
36
-
37
- sleep 2
38
-
39
- out = `nice -n20 ab -c #{c} -n #{n} http://127.0.0.1:#{port}/ 2> /dev/null`
40
-
41
- Process.kill('SIGKILL', server)
42
- Process.wait
43
-
44
- if requests = out.match(/^Requests.+?(\d+\.\d+)/)
45
- requests[1].to_i
46
- else
47
- 0
48
- end
49
- end
50
-
51
- def benchmark(type, servers, request, concurrency_levels)
52
- send "#{type}_benchmark", servers, request, concurrency_levels
53
- end
54
-
55
- def graph_benchmark(servers, request, concurrency_levels)
56
- require '/usr/local/lib/ruby/gems/1.8/gems/gruff-0.2.9/lib/gruff'
57
- g = Gruff::Area.new
58
- g.title = "Server benchmark"
59
-
60
- servers.each do |server|
61
- g.data(server, concurrency_levels.collect { |c| print '.'; run(server, request, c) })
62
- end
63
- puts
64
-
65
- g.x_axis_label = 'Concurrency'
66
- g.y_axis_label = 'Requests / sec'
67
- g.labels = {}
68
- concurrency_levels.each_with_index { |c, i| g.labels[i] = c.to_s }
69
-
70
- g.write('bench.png')
71
- `open bench.png`
72
- end
73
-
74
- def print_benchmark(servers, request, concurrency_levels)
75
- puts 'server request concurrency req/s'
76
- puts '=' * 42
77
- concurrency_levels.each do |c|
78
- servers.each do |server|
79
- puts "#{server.ljust(8)} #{request} #{c.to_s.ljust(4)} #{run(server, request, c)}"
80
- end
81
- end
82
- end