Skip to content

Instantly share code, notes, and snippets.

@kossnocorp
Created December 15, 2013 08:35
Show Gist options
  • Select an option

  • Save kossnocorp/7970440 to your computer and use it in GitHub Desktop.

Select an option

Save kossnocorp/7970440 to your computer and use it in GitHub Desktop.
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