N = number of hits to single page in the application
All times in seconds
Numbers: Mean (Standard Deviation)
Tweaks:
1. JRuby 1.0.1 + Rails 1.2.3, client vm
2. 1 + turn off objectspace (-Djruby.objectspace.enabled=false)
2a. 2 + http://headius.blogspot.com/2007/10/another-performance-discovery-rexml.html
3. 2 + JREXML http://caldersphere.rubyforge.org/jrexml
4. 3 + http://headius.blogspot.com/2007/10/another-performance-discovery-rexml.html
5. 3 except with JRuby trunk
6. 5 except with server vm (-server)
Benchmark script (ruby)
def benchmark_request(url, n = nil)
n ||= ENV['N'] && ENV['N'].to_i || 10
require 'net/https'
require 'benchmark'
uri = URI.parse(url)
get = Net::HTTP::Get.new(uri.path)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true if uri.scheme == "https"
results = Hash.new {|h,k| h[k] = 0}
times = (1..n).map do
bm = Benchmark.measure do
res = http.start {|h| h.request(get)}
results[res.code] += 1
end
puts bm
bm
end
sum = times.inject(0) {|s,t| s + t.real}
mean = sum / n
sumsq = times.inject(0) {|s,t| s + t.real * t.real}
sd = Math.sqrt((sumsq - (sum * sum / n)) / (n - 1))
puts("Mean: %0.6f SDev: %0.6f" % [mean, sd])
puts results.inject("Responses: ") {|str,kv| str << "#{kv.first}: #{kv.last} "}
end