Created
January 12, 2010 21:16
-
-
Save kplawver/275619 to your computer and use it in GitHub Desktop.
Helps simplify and automate apache benchmark runs.
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
## Loader | |
# Does a pre-configured set of apache benchmark on an array of URLs passed in. | |
# Yes, it's silly, but it saved me a lot of time today. | |
# | |
# Usage: Loadr.test(['http://cnn.com','http://lwvr.net'],"news_and_me") | |
# - Created a log file for each URL, then fills it with the results of its ab runs. | |
# - Only works on OS's where ab is in the path. | |
class Loadr | |
@@run_sets = [ | |
[1,10], | |
[5,50], | |
[10,50], | |
[15,50], | |
[20,80] | |
] | |
def self.test(urls,log_name="test") | |
i = 0 | |
urls.each do |url| | |
i = i+1 | |
puts "Starting #{i}: #{url}" | |
log = File.open("#{ENV['PWD']}/#{log_name}_#{i}.log","w+") | |
log.puts "Load Test Runs for #{url}:\n\n" | |
@@run_sets.each do |set| | |
puts "-- Starting set: #{set[0]}, #{set[1]}" | |
log.puts "#{set[0]} concurrent, #{set[1]} total requests\n\n" | |
log.puts `ab -c #{set[0]} -n #{set[1]} #{url}` | |
log.puts "\n\n------------------------------------------------------\n\n" | |
end | |
log.close | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment