Skip to content

Instantly share code, notes, and snippets.

@blambeau
Created November 22, 2011 09:15
Show Gist options
  • Save blambeau/1385268 to your computer and use it in GitHub Desktop.
Save blambeau/1385268 to your computer and use it in GitHub Desktop.
Thin test
require 'http'
NB = 5
times = []
threads = (0..NB).map do |i|
Thread.new(i) {|nb|
t1 = Time.now
puts Http.get("http://127.0.0.1:3000")
t2 = Time.now
times[nb] = (t2-t1)
}
end
threads.map{|t| t.join}
puts times.inspect
avg = times.inject(0.0){|avg,t| avg + t}/NB
puts "#{avg} sec/req"
run lambda{|env|
sleep(1)
[200, {"Content-Type" => "text/plain"}, ["Done."]]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment