Created
December 15, 2013 08:35
-
-
Save kossnocorp/7970440 to your computer and use it in GitHub Desktop.
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 characters
| ACCESS_KEY_ID = 'xxx' | |
| SECRET_ACCESS_KEY = 'xxx' | |
| COUNT_OF_REQUETS = 100 | |
| task :test do | |
| ec2 = AWS::EC2.new(access_key_id: ACCESS_KEY_ID, secret_access_key: SECRET_ACCESS_KEY) | |
| results = ec2.regions.map do |region| | |
| mean = `ab -c 1 -n #{COUNT_OF_REQUETS} #{region.endpoint}/ping | perl -n -e'/([\\d\\.]+)(?= \\[ms\\] \\(mean\\))/ && print $1'`.to_f | |
| {name: region.name, mean: mean} | |
| end | |
| results.sort { |a, b| a[:mean] <=> b[:mean] }.each do |r| | |
| puts "[#{r[:name]}]" | |
| puts r[:mean] | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment