ry / ebb fork watch download tarball
public
Description: web server
Homepage: http://ebb.rubyforge.org
Clone URL: git://github.com/ry/ebb.git
Search Repo:
merge test files
Ryan Dahl (author)
Sat Feb 16 17:37:31 -0800 2008
commit  8e8b428d6fead26dbea463217be5d51109a877fd
tree    8a9ca53d7f55c01dbf2c7bbe114a98032782557b
parent  7dde0e01cda103cf775aa8c2198e8f4b6d0da0ea
...
150
151
152
153
 
154
155
156
...
175
176
177
178
 
179
180
181
...
150
151
152
 
153
154
155
156
...
175
176
177
 
178
179
180
181
0
@@ -150,7 +150,7 @@
0
     
0
     print "#{@name} (c=#{concurrency},s=#{size}) "
0
     $stdout.flush
0
- r = %x{ab -t 3 -q -c #{concurrency} http://0.0.0.0:#{@port}//#{size}}
0
+ r = %x{ab -t 3 -q -c #{concurrency} http://0.0.0.0:#{@port}/bytes/#{size}}
0
     # Complete requests: 1000
0
 
0
     return nil unless r =~ /Requests per second:\s*(\d+\.\d\d)/
0
@@ -175,7 +175,7 @@
0
     
0
     print "#{@name} (c=#{concurrency},wait=#{wait}) "
0
     $stdout.flush
0
- r = %x{ab -t #{wait*3} -q -c #{concurrency} http://0.0.0.0:#{@port}/periodically_slow_#{wait}}
0
+ r = %x{ab -t #{wait*3} -q -c #{concurrency} http://0.0.0.0:#{@port}/periodical_activity/wait/#{wait}}
0
     # Complete requests: 1000
0
 
0
     return nil unless r =~ /Requests per second:\s*(\d+\.\d\d)/
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
 
 
 
 
 
4
5
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
8
9
10
...
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
...
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
...
61
62
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
65
66
67
68
69
70
71
72
0
@@ -1,9 +1,53 @@
0
+DIR = File.dirname(__FILE__)
0
+
0
+def fib(n)
0
+ return 1 if n <= 1
0
+ fib(n-1) + fib(n-2)
0
+end
0
+
0
+def wait(seconds)
0
+ n = (seconds / 0.01).to_i
0
+ n.times do
0
+ sleep(0.01)
0
+ #File.read(DIR + '/yahoo.html')
0
+ end
0
+end
0
+
0
 class SimpleApp
0
   @@responses = {}
0
- @@count = 0
0
+
0
+ def initialize
0
+ @count = 0
0
+ end
0
+
0
   def call(env)
0
- command = env['PATH_INFO'].split('/').last
0
- if command == "test_post_length"
0
+ commands = env['PATH_INFO'].split('/')
0
+
0
+ @count += 1
0
+ if commands.include?('periodical_activity') and @count % 10 != 1
0
+ return [200, {'Content-Type'=>'text/plain'}, "quick response!\r\n"]
0
+ end
0
+
0
+ if commands.include?('fibonacci')
0
+ n = commands.last.to_i
0
+ raise "fibonacci called with n <= 0" if n <= 0
0
+ body = (1..n).to_a.map { |i| fib(i).to_s }.join(' ')
0
+ status = 200
0
+
0
+ elsif commands.include?('wait')
0
+ n = commands.last.to_i
0
+ raise "wait called with n <= 0" if n <= 0
0
+ wait(n)
0
+ body = "waited about #{n} seconds"
0
+ status = 200
0
+
0
+ elsif commands.include?('bytes')
0
+ n = commands.last.to_i
0
+ raise "bytes called with n <= 0" if n <= 0
0
+ body = @@responses[n] || "C"*n
0
+ status = 200
0
+
0
+ elsif commands.include?('test_post_length')
0
       input_body = ""
0
       while chunk = env['rack.input'].read(10)
0
         input_body << chunk
0
0
@@ -17,33 +61,12 @@
0
           input_body.length = #{input_body.length}"
0
         status = 500
0
       end
0
- elsif command =~ /periodically_slow_(\d+)$/
0
- if @@count % 10 == 0
0
- seconds = $1.to_i
0
- #puts "sleeping #{seconds}"
0
- sleep seconds
0
- #puts "done"
0
- else
0
- seconds = 0
0
- end
0
- @@count += 1
0
- body = "waited #{seconds} seconds"
0
- elsif command =~ /slow_(\d+)$/
0
- seconds = $1.to_i
0
- #puts "sleeping #{seconds}"
0
- sleep seconds
0
- #puts "done"
0
- status = 200
0
- body = "waited #{seconds} seconds"
0
- elsif command.to_i > 0
0
- size = command.to_i
0
- @@responses[size] ||= "C" * size
0
- body = @@responses[size]
0
- status = 200
0
+
0
     else
0
       status = 404
0
       body = "Undefined url"
0
     end
0
+
0
     [status, {'Content-Type' => 'text/plain'}, body + "\r\n\r\n"]
0
   end
0
 end

Comments

    No one has commented yet.