Added sorting
This commit is contained in:
parent
1063208d4d
commit
abd63a7fad
@ -130,7 +130,10 @@ def run_benchmark(num_workers: int, timeout: float, filename: str):
|
|||||||
|
|
||||||
assert count_requests_completed == len(all_requests_completed)
|
assert count_requests_completed == len(all_requests_completed)
|
||||||
|
|
||||||
return all_requests_completed
|
final_sorted_results = list(all_requests_completed.values())
|
||||||
|
final_sorted_results.sort(key=lambda a: a.upload_started) # sort by upload start time
|
||||||
|
|
||||||
|
return final_sorted_results
|
||||||
|
|
||||||
|
|
||||||
def csv_time_format(timestamp: Optional[float]) -> Optional[str]:
|
def csv_time_format(timestamp: Optional[float]) -> Optional[str]:
|
||||||
@ -148,7 +151,7 @@ def write_results(results, file_handle):
|
|||||||
['id', 'http_start_time', 'http_complete_time', 'status_code', 'mqtt_arrive_time', 'latency', 'rtt']
|
['id', 'http_start_time', 'http_complete_time', 'status_code', 'mqtt_arrive_time', 'latency', 'rtt']
|
||||||
)
|
)
|
||||||
|
|
||||||
for result in results.values():
|
for result in results:
|
||||||
latency = (result.alert_arrived - result.upload_finished) * 1000 if result.alert_arrived else None
|
latency = (result.alert_arrived - result.upload_finished) * 1000 if result.alert_arrived else None
|
||||||
rtt = (result.alert_arrived - result.upload_started) * 1000 if result.alert_arrived else None
|
rtt = (result.alert_arrived - result.upload_started) * 1000 if result.alert_arrived else None
|
||||||
|
|
||||||
@ -233,7 +236,7 @@ def main():
|
|||||||
print("Waiting for inflight MQTT messages to arrive...")
|
print("Waiting for inflight MQTT messages to arrive...")
|
||||||
# Wait for inflight messages for a little
|
# Wait for inflight messages for a little
|
||||||
|
|
||||||
total_successful_uploads = len([req for req in benchmark_results.values() if req.upload_status_code == 200])
|
total_successful_uploads = len([req for req in benchmark_results if req.upload_status_code == 200])
|
||||||
all_arrived = False
|
all_arrived = False
|
||||||
waiting_started = time.time()
|
waiting_started = time.time()
|
||||||
for _ in range(int(args.inflight_timeout * 1000)):
|
for _ in range(int(args.inflight_timeout * 1000)):
|
||||||
@ -268,8 +271,8 @@ def main():
|
|||||||
total_answered += 1
|
total_answered += 1
|
||||||
|
|
||||||
# print some mini statistics
|
# print some mini statistics
|
||||||
total_runtime = max(benchmark_results.values(), key=lambda a: a.upload_finished).upload_finished - \
|
total_runtime = max(benchmark_results, key=lambda a: a.upload_finished).upload_finished - \
|
||||||
min(benchmark_results.values(), key=lambda a: a.upload_started).upload_started
|
min(benchmark_results, key=lambda a: a.upload_started).upload_started
|
||||||
|
|
||||||
print(
|
print(
|
||||||
f"{len(benchmark_results)} requests completed: {total_successful_uploads} successfully uploaded and {total_answered} answered"
|
f"{len(benchmark_results)} requests completed: {total_successful_uploads} successfully uploaded and {total_answered} answered"
|
||||||
|
Loading…
Reference in New Issue
Block a user