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):
break
current += 1
n_queries = connection.nbr_finished_queries
stop = time.time()
if opts.tests > 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))
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/(n_queries-1))
else:
extra = ""
if not opts.check or opts.verbose:
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))
if opts.multistreams and opts.verbose:
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
# Main program
......
......@@ -53,6 +53,7 @@ class Connection:
self.forceIPv6 = forceIPv6
self.connect_to = connect_to
self.state = 'CONN_OK'
self.nbr_finished_queries = 0
def __str__(self):
return self.server
......@@ -242,6 +243,7 @@ class ConnectionDOT(Connection):
def receive_data(self, dump=False):
try:
buf = self.session.recv(2)
self.nbr_finished_queries += 1
except OpenSSL.SSL.WantReadError:
return (False, None, None)
except OpenSSL.SSL.ZeroReturnError:
......@@ -451,6 +453,7 @@ class ConnectionDOH(Connection):
raise homer.DOHException(e.args[1])
def receive(self, handle):
self.nbr_finished_queries += 1
request = handle.request
body = handle.buffer.getvalue()
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