Created
January 11, 2014 21:57
-
-
Save josecolella/8377483 to your computer and use it in GitHub Desktop.
Automatizar los benchmarks
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 python3 | |
import os | |
import sys | |
def generateAbBenchmarks(argument): | |
for i in range(1, 6): | |
if argument == "azure1": | |
p = os.popen( | |
"ab -n 1000 -c 100 http://ivmachine.cloudapp.net/index.html", "r") | |
elif argument == "azure2": | |
p = os.popen( | |
"ab -n 1000 -c 100 http://ivmachine2.cloudapp.net/index.html", "r") | |
elif argument == "aws1": | |
p = os.popen( | |
"ab -n 1000 -c 100 http://ec2-54-194-187-157.eu-west-1.compute.amazonaws.com/index.html", "r") | |
elif argument == "aws2": | |
p = os.popen( | |
"ab -n 1000 -c 100 ec2-54-194-113-118.eu-west-1.compute.amazonaws.com/index.html", "r") | |
print("Iteration: {}".format(i)) | |
fo = open("ab{}{}.txt".format(argument, i), "w") | |
line = p.readline() | |
while line != '': | |
fo.write(line) | |
line = p.readline() | |
fo.close() | |
def generateHTTPPerfBenchmarks(argument): | |
for i in range(1, 6): | |
if argument == "azure1": | |
p = os.popen( | |
"httperf --server http://ivmachine.cloudapp.net/ --port 80 --rate 10 --num-conn 1000 --uri /index.html", "r") | |
elif argument == "azure2": | |
p = os.popen( | |
"httperf --server http://ivmachine2.cloudapp.net/ --port 80 --rate 10 --num-conn 1000 --uri /index.html", "r") | |
elif argument == "aws1": | |
p = os.popen( | |
"httperf --server http://ec2-54-194-187-157.eu-west-1.compute.amazonaws.com --port 80 --rate 10 --num-conn 1000 --uri /index.html", "r") | |
elif argument == "aws2": | |
p = os.popen( | |
"httperf --server http://ec2-54-194-113-118.eu-west-1.compute.amazonaws.com/ --port 80 --rate 10 --num-conn 1000 --uri /index.html", "r") | |
print("Iteration: {}".format(i)) | |
fo = open("httpPerf{}{}.txt".format(argument, i), "w") | |
line = p.readline() | |
while line != '': | |
fo.write(line) | |
line = p.readline() | |
fo.close() | |
if __name__ == '__main__': | |
try: | |
generateAbBenchmarks(sys.argv[1]) | |
generateHTTPPerfBenchmarks(sys.argv[1]) | |
except Exception: | |
print("Tiene que haber un argumento: <azure1>, <azure2> o <aws1>, <aws2>") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment