Last active
December 15, 2015 12:19
-
-
Save jmervine/5258983 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
require 'json' | |
require 'httperf' | |
# gem install httperfrb | |
# see: http://github.com/rubyops/httperfrb | |
server = ENV['HTTPERF_HOST'] || "localhost" | |
uri = ENV['HTTPERF_URI'] || "/" | |
conns = ENV['HTTPERF_CONNS'] || 10 | |
httperf = HTTPerf.new( "server" => server, "num-conns" => conns, "uri" => uri, "rate" => 1, "verbose" => true, "parse" => true ) | |
puts "Starting: #{httperf.command}" | |
file = "test-#{Time.now.strftime("%Y%jT%H%M%S")}" | |
result = httperf.run | |
File.open("#{file}.json", "w") do |f| | |
f.print result.to_json | |
end | |
File.open("#{file}.txt", "w") do |f| | |
[ :total_connections, | |
:connection_rate_per_sec, | |
:connection_time_min, | |
:connection_time_avg, | |
:connection_time_max, | |
:errors_total, | |
:connection_time_85_pct, | |
:connection_time_95_pct, | |
:connection_time_99_pct ].each do |k| | |
title = k.to_s.gsub("_", " ").capitalize+":" | |
f.printf "%-25s %s\n", title, result[k].to_s | |
printf "%-25s %s\n", title, result[k].to_s | |
end | |
end | |
puts "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run like: