ry / ebb fork watch download tarball
public this repo is viewable by everyone
Description: web server
Homepage: http://ebb.rubyforge.org
Clone URL: git://github.com/ry/ebb.git
start on unified bench script
Ryan Dahl (author)
2 months ago
commit  a791fbb16843b516dbb8e50aa9e4e007c391c927
tree    21e9aba300b3e4eae2482293d8c625b472c35840
parent  e371bdae561942f088985098dece7eed08e28e85
...
40
41
42
43
 
44
45
46
...
40
41
42
 
43
44
45
46
0
@@ -40,7 +40,7 @@ spec = Gem::Specification.new do |s|
0
   s.files = FileList.new('src/*.{c,h}',
0
                          'src/extconf.rb',
0
                          'libev/*',
0
- 'ruby_lib/*',
0
+ 'ruby_lib/**/*',
0
                          'benchmark/*.rb',
0
                          'bin/ebb_rails',
0
                          'VERSION',
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
0
@@ -0,0 +1,14 @@
0
+require File.dirname(__FILE__) + "/server_test
0
+"
0
+# supported servers: mongrel, emongrel, ebb, thin
0
+# use another name an a already open port for anything else
0
+usage = "e.g. server_bench response_size ebb:4001 mongrel:4002 other:4003"
0
+
0
+bench_name = ARGV.shift
0
+
0
+servers = []
0
+ARGV.each do |server|
0
+ name, port = server.split(':')
0
+ servers << ServerTest.new(name, port)
0
+end
0
+
...
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
...
140
141
142
143
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
145
146
...
231
232
233
234
235
236
237
...
 
1
2
3
4
5
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
8
9
...
86
87
88
 
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
...
215
216
217
 
218
219
220
0
@@ -1,63 +1,9 @@
0
-$: << File.expand_path(File.dirname(__FILE__) + '/..')
0
+$: << File.expand_path(File.dirname(__FILE__))
0
 
0
 require 'rubygems'
0
 require 'rack'
0
 require 'application'
0
 
0
-module Bytes
0
- def bytes
0
- self
0
- end
0
- alias :byte :bytes
0
-
0
- def kilobytes
0
- self * 1024
0
- end
0
- alias :kilobyte :kilobytes
0
-
0
- def megabytes
0
- self * 1024.kilobytes
0
- end
0
- alias :megabyte :megabytes
0
-
0
- def gigabytes
0
- self * 1024.megabytes
0
- end
0
- alias :gigabyte :gigabytes
0
-
0
- def terabytes
0
- self * 1024.gigabytes
0
- end
0
- alias :terabyte :terabytes
0
-
0
- def petabytes
0
- self * 1024.terabytes
0
- end
0
- alias :petabyte :petabytes
0
-
0
- def exabytes
0
- self * 1024.petabytes
0
- end
0
- alias :exabyte :exabytes
0
-
0
-end
0
-class Fixnum
0
- include Bytes
0
-end
0
-
0
-def number_to_human_size(size, precision=1)
0
- size = Kernel.Float(size)
0
- case
0
- when size.to_i == 1; "1 Byte"
0
- when size < 1.kilobyte; "%d Bytes" % size
0
- when size < 1.megabyte; "%.#{precision}f KB" % (size / 1.0.kilobyte)
0
- when size < 1.gigabyte; "%.#{precision}f MB" % (size / 1.0.megabyte)
0
- when size < 1.terabyte; "%.#{precision}f GB" % (size / 1.0.gigabyte)
0
- else "%.#{precision}f TB" % (size / 1.0.terabyte)
0
- end.sub(/([0-9])\.?0+ /, '\1 ' )
0
-rescue
0
- nil
0
-end
0
 
0
 class Array
0
   def avg
0
@@ -140,7 +86,45 @@ class ServerTest
0
   
0
   def start
0
     puts "Starting #{name}"
0
- @pid = fork { @start_block.call }
0
+ case name
0
+ when 'emongrel'
0
+ @pid = fork { start_emongrel }
0
+ when 'ebb'
0
+ @pid = fork { start_ebb }
0
+ when 'mongrel'
0
+ @pid = fork { start_mongrel }
0
+ when 'thin'
0
+ @pid = fork { start_thin }
0
+ else
0
+ @pid = fork { @start_block.call }
0
+ end
0
+ end
0
+
0
+ def app
0
+ SimpleApp.new
0
+ end
0
+
0
+ def start_emongrel
0
+ require 'mongrel'
0
+ require 'swiftcore/evented_mongrel'
0
+ ENV['EVENT'] = "1"
0
+ Rack::Handler::Mongrel.run(app, :Port => @port)
0
+ end
0
+
0
+ def start_ebb
0
+ require File.dirname(__FILE__) + '/../ruby_lib/ebb'
0
+ server = Ebb::Server.new(app, :port => @port)
0
+ server.start
0
+ end
0
+
0
+ def start_mongrel
0
+ require 'mongrel'
0
+ Rack::Handler::Mongrel.run(app, :Port => @port)
0
+ end
0
+
0
+ def start_thin
0
+ require 'thin'
0
+ Rack::Handler::Thin.run(app, :Port => @port)
0
   end
0
   
0
   def trial(options = {})
0
@@ -231,7 +215,6 @@ class ServerTest
0
 end
0
 
0
 $servers = []
0
-app = SimpleApp.new
0
 $servers << ServerTest.new('emongrel', 4001) do
0
   require 'mongrel'
0
   require 'swiftcore/evented_mongrel'

Comments

    No one has commented yet.