Created
November 22, 2011 09:15
-
-
Save blambeau/1385268 to your computer and use it in GitHub Desktop.
Thin test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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