Commit 593559ea authored by Stephane Bortzmeyer's avatar Stephane Bortzmeyer
Browse files

Allows to sleep between requests. Closes #3

parent 56b1904a
......@@ -21,6 +21,7 @@ head = False
rtype = 'AAAA'
tests = 1 # Number of repeated tests
ifile = None # Input file
delay = None
def error(msg=None):
if msg is None:
......@@ -37,8 +38,8 @@ def usage(msg=None):
name = None
message = None
try:
optlist, args = getopt.getopt (sys.argv[1:], "hvPker:f:",
["help", "verbose", "head", "insecure", "POST", "repeat=", "file="])
optlist, args = getopt.getopt (sys.argv[1:], "hvPker:f:d:",
["help", "verbose", "head", "insecure", "POST", "repeat=", "file=", "delay="])
for option, value in optlist:
if option == "--help" or option == "-h":
usage()
......@@ -55,6 +56,10 @@ try:
tests = int(value)
if tests <= 1:
error("--repeat needs a value > 1")
elif option == "--delay" or option == "-d":
delay = float(value)
if delay <= 0:
error("--delay needs a value > 0")
elif option == "--file" or option == "-f":
ifile = value
else:
......@@ -62,6 +67,8 @@ try:
except getopt.error as reason:
usage(reason)
sys.exit(1)
if tests <= 1 and delay is not None:
error("--delay makes no sense if there is no repetition")
if post and head:
usage("POST or HEAD but not both")
sys.exit(1)
......@@ -150,6 +157,8 @@ for i in range (0, tests):
buffer.close()
if tests > 1 and i == 0:
start2 = time.time()
if delay is not None:
time.sleep(delay)
c.close()
stop = time.time()
if tests > 1:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment