##// END OF EJS Templates
scripts: added timeout flag to load script measuring url times
marcink -
r3858:1ae1aad2 default
parent child Browse files
Show More
@@ -29,7 +29,8 b' log = logging.getLogger(__name__)'
29 @click.option('--server', help='Server url to connect to. e.g http://rc.local.com', required=True)
29 @click.option('--server', help='Server url to connect to. e.g http://rc.local.com', required=True)
30 @click.option('--pages', help='load pages to visit from a file', required=True, type=click.File())
30 @click.option('--pages', help='load pages to visit from a file', required=True, type=click.File())
31 @click.option('--repeat', help='number of times to repeat', default=10, type=int)
31 @click.option('--repeat', help='number of times to repeat', default=10, type=int)
32 def main(server, repeat, pages):
32 @click.option('--timeout', help='call timeout', default=60, type=int)
33 def main(server, repeat, pages, timeout):
33
34
34 print("Repeating each URL %d times\n" % repeat)
35 print("Repeating each URL %d times\n" % repeat)
35 pages = pages.readlines()
36 pages = pages.readlines()
@@ -39,7 +40,7 b' def main(server, repeat, pages):'
39 url = "%s/%s" % (server, page_url.strip())
40 url = "%s/%s" % (server, page_url.strip())
40 print(url)
41 print(url)
41
42
42 stmt = "requests.get('%s', timeout=120)" % url
43 stmt = "requests.get('{}', timeout={})".format(url, timeout)
43 t = timeit.Timer(stmt=stmt, setup="import requests")
44 t = timeit.Timer(stmt=stmt, setup="import requests")
44
45
45 result = t.repeat(repeat=repeat, number=1)
46 result = t.repeat(repeat=repeat, number=1)
General Comments 0
You need to be logged in to leave comments. Login now