-
-
Save flores/1198501 to your computer and use it in GitHub Desktop.
Revisions
-
evanphx created this gist
Sep 6, 2011 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ require 'socket' profile = false if ARGV.first == "-p" profile = true ARGV.shift end port = ARGV.shift count = ARGV.shift all = count.to_i.times.map do s = TCPSocket.new "0.0.0.0", port.to_i start = Time.now s << "GET /perf/index HTTP/1.0\r\n" s << "Host: 0.0.0.0:3001\r\n" s << "X-Profile: true\r\n" if profile s << "User-Agent: ApacheBench/2.3\r\n" s << "Accept: */*\r\n\r\n" s.read Time.now.to_f - start.to_f end sum = all.inject { |a,i| a + i} mean = sum / count.to_i.to_f puts "mean: #{mean}" puts "r/s: #{1.0 / mean}"