public
Description: Phusion Passenger (mod_rails)
Homepage: http://www.modrails.com/
Clone URL: git://github.com/FooBarWidget/passenger.git
Search Repo:
Click here to lend your support to: passenger and make a donation at www.pledgie.com !
Add benchmark tool for the Rails Dispatcher.
Hongli Lai (Phusion) (author)
Tue Apr 01 14:06:00 -0700 2008
commit  e086712b4a9bfaed826511abfeda10f855f012fc
tree    8a5bc61b710f1596abd547f5fb5c64b585bcbd70
parent  dc0217ae01146302770b9bddddc7887d14e67977
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
0
@@ -1 +1,47 @@
0
+#!/usr/bin/env ruby
0
+# Benchmark raw speed of the Rails dispatcher.
0
+PASSENGER_ROOT = File.expand_path("#{File.dirname(__FILE__)}/..")
0
+$LOAD_PATH << "#{PASSENGER_ROOT}/lib"
0
+ENV["RAILS_ENV"] = "production"
0
+
0
+require 'yaml'
0
+require 'benchmark'
0
+require 'passenger/request_handler'
0
+require 'config/environment'
0
+require 'dispatcher'
0
+
0
+include Passenger
0
+
0
+class OutputChannel
0
+ def write(data)
0
+ # Black hole
0
+ end
0
+end
0
+
0
+def start(iterations)
0
+ headers = YAML.load_file("#{PASSENGER_ROOT}/test/stub/http_request.yml")
0
+ output = OutputChannel.new
0
+ milestone = iterations / 10
0
+ milestone = 1 if milestone == 0
0
+ result = Benchmark.measure do
0
+ iterations.times do |i|
0
+ cgi = CGIFixed.new(headers, output, STDOUT)
0
+ ::Dispatcher.dispatch(cgi,
0
+ ::ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS,
0
+ cgi.stdoutput)
0
+ if i % milestone == 0 && i != 0
0
+ puts "Completed #{i} requests"
0
+ end
0
+ end
0
+ end
0
+ puts "#{iterations} requests: #{result}"
0
+ printf "Speed: %.2f requests/sec\n", iterations / result.total.to_f
0
+end
0
+
0
+puts "Benchmark started."
0
+t = Thread.new do
0
+ #start(ARGV[0] ? ARGV[0].to_i : 1000)
0
+end
0
+start(ARGV[0] ? ARGV[0].to_i : 1000)
0
+t.join
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
0
@@ -1 +1,24 @@
0
+---
0
+SERVER_NAME: rails.test
0
+HTTP_ACCEPT_ENCODING: gzip,deflate
0
+HTTP_USER_AGENT: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9b3pre) Gecko/2008020507 Firefox/3.0b3pre
0
+HTTP_CACHE_CONTROL: max-age=0
0
+HTTP_IF_NONE_MATCH: "\"4b3ecee644e12a7a2203be7484eaecfc\""
0
+HTTP_ACCEPT_LANGUAGE: en-us,en;q=0.5
0
+HTTP_HOST: rails.test
0
+SERVER_ADDR: 127.0.0.1
0
+SERVER_PROTOCOL: HTTP/1.1
0
+HTTP_KEEP_ALIVE: "300"
0
+REMOTE_ADDR: 127.0.0.1
0
+SERVER_SOFTWARE: Apache/2.2.4 (Ubuntu) mod_fastcgi/2.4.2 PHP/5.2.3-1ubuntu6.3 mod_ssl/2.2.4 OpenSSL/0.9.8e Phusion_Passenger/0.9.6
0
+HTTP_ACCEPT_CHARSET: ISO-8859-1,utf-8;q=0.7,*;q=0.7
0
+DOCUMENT_ROOT: /var/www/projects/app1-foobar/public
0
+REQUEST_URI: /
0
+SERVER_PORT: "80"
0
+QUERY_STRING: ""
0
+REMOTE_PORT: "36128"
0
+SERVER_ADMIN: "[no address given]"
0
+HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
0
+HTTP_CONNECTION: keep-alive
0
+REQUEST_METHOD: GET

Comments

    No one has commented yet.