Commit 15c52565 authored by Alexandre's avatar Alexandre
Browse files

Use number of received queries for elapsed time

Calculate the elapsed time per query based on the number of finished
queries and not the number of wanted queries.
parent bef36122
...@@ -575,18 +575,19 @@ def run_default(name, connection, opts): ...@@ -575,18 +575,19 @@ def run_default(name, connection, opts):
break break
current += 1 current += 1
n_queries = connection.nbr_finished_queries
stop = time.time() stop = time.time()
if opts.tests > 1 and not opts.pipelining and not opts.multistreams: if n_queries > 1 and not opts.pipelining and not opts.multistreams:
extra = ", %.2f ms/request if we ignore the first one" % ((stop-start2)*1000/(opts.tests-1)) extra = ", %.2f ms/request if we ignore the first one" % ((stop-start2)*1000/(n_queries-1))
else: else:
extra = "" extra = ""
if not opts.check or opts.verbose: if not opts.check or opts.verbose:
time_tot = stop - start time_tot = stop - start
time_per_request = time_tot / opts.tests * 1000 time_per_request = time_tot / n_queries * 1000
print("\nTotal elapsed time: %.2f seconds (%.2f ms/request%s)" % (time_tot, time_per_request, extra)) print("\nTotal elapsed time: %.2f seconds (%.2f ms/request%s)" % (time_tot, time_per_request, extra))
if opts.multistreams and opts.verbose: if opts.multistreams and opts.verbose:
for rcode, n in conn.finished['http'].items(): for rcode, n in conn.finished['http'].items():
print("HTTP %d : %d %.2f%%" % (rcode, n, n / opts.tests * 100)) print("HTTP %d : %d %.2f%%" % (rcode, n, n / n_queries * 100))
return ok return ok
# Main program # Main program
......
...@@ -53,6 +53,7 @@ class Connection: ...@@ -53,6 +53,7 @@ class Connection:
self.forceIPv6 = forceIPv6 self.forceIPv6 = forceIPv6
self.connect_to = connect_to self.connect_to = connect_to
self.state = 'CONN_OK' self.state = 'CONN_OK'
self.nbr_finished_queries = 0
def __str__(self): def __str__(self):
return self.server return self.server
...@@ -242,6 +243,7 @@ class ConnectionDOT(Connection): ...@@ -242,6 +243,7 @@ class ConnectionDOT(Connection):
def receive_data(self, dump=False): def receive_data(self, dump=False):
try: try:
buf = self.session.recv(2) buf = self.session.recv(2)
self.nbr_finished_queries += 1
except OpenSSL.SSL.WantReadError: except OpenSSL.SSL.WantReadError:
return (False, None, None) return (False, None, None)
except OpenSSL.SSL.ZeroReturnError: except OpenSSL.SSL.ZeroReturnError:
...@@ -451,6 +453,7 @@ class ConnectionDOH(Connection): ...@@ -451,6 +453,7 @@ class ConnectionDOH(Connection):
raise homer.DOHException(e.args[1]) raise homer.DOHException(e.args[1])
def receive(self, handle): def receive(self, handle):
self.nbr_finished_queries += 1
request = handle.request request = handle.request
body = handle.buffer.getvalue() body = handle.buffer.getvalue()
body_size = len(body) body_size = len(body)
......
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