Commit b50e99a5 authored by Alexandre's avatar Alexandre
Browse files

Calculate average query time with streams. See #26

parent 6ae3cef7
......@@ -590,7 +590,9 @@ class ConnectionDoH(Connection):
print(f'{handle.time * 1000:6.3f} ms', end=' ')
print(f'{(handle.time - handle.pretime) * 1000:6.3f} ms')
if not silent:
print("Return code %s:\n%s\n" % (handle.request.rcode, handle.request.response))
print("Return code %s (%.2f ms):" % (handle.request.rcode,
(handle.time - handle.pretime) * 1000))
print(f"{handle.request.response}\n")
handle.close()
self.multi.remove_handle(handle)
......@@ -1110,17 +1112,27 @@ for connectTo in ip_set:
if multistreams:
conn.perform_multi()
if sync:
print()
conn.read_results()
else:
ok = run_check(conn) and ok # need to run run_check first
stop = time.time()
if tests > 1:
extra = ", %.2f ms/request if we ignore the first one" % ((stop-start2)*1000/(tests-1))
if multistreams:
time_tot_not_first = sum(handle.time - handle.pretime for handle in conn.all_handles)
time_tot_not_first -= (conn.first_handle.time - conn.first_handle.pretime)
else:
time_tot_not_first = stop - start2
time_req_not_first = time_tot_not_first * 1000 / (tests - 1)
extra = ", %.2f ms/request if we ignore the first one" % time_req_not_first
else:
extra = ""
if not monitoring and (not check or verbose):
print("\nTotal elapsed time: %.2f seconds (%.2f ms/request %s)" % (stop-start, (stop-start)*1000/tests, extra))
time_tot = stop - start
if multistreams:
time_per_request = sum(handle.time - handle.pretime for handle in conn.all_handles) / tests * 1000
else:
time_per_request = time_tot / tests * 1000
print("\nTotal elapsed time: %.2f seconds (%.2f ms/request %s)" % (time_tot, time_per_request, extra))
if ifile is not None:
input.close()
conn.end()
......
Supports Markdown
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