From 2910c0a2e28886b36425c5191c787f76b07e6787 Mon Sep 17 00:00:00 2001 From: marcsello Date: Fri, 23 Oct 2020 17:31:23 +0200 Subject: [PATCH] Fixed target url --- benchmark3.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/benchmark3.py b/benchmark3.py index c04a903..24b94f3 100644 --- a/benchmark3.py +++ b/benchmark3.py @@ -31,9 +31,9 @@ class ReturnedRequest: arrived: float -def independent_worker(result_queue, filename: str, timeout: float): +def independent_worker(result_queue, filename: str, timeout: float, target_url: str): prepared_curl = pycurl.Curl() - prepared_curl.setopt(pycurl.URL, "https://birb.k8s.kmlabz.com/benchmark") + prepared_curl.setopt(pycurl.URL, target_url) prepared_curl.setopt(pycurl.SSL_VERIFYPEER, 0) prepared_curl.setopt(pycurl.SSL_VERIFYHOST, 0) # prepared_curl.setopt(pycurl.FORBID_REUSE, 0) @@ -101,14 +101,14 @@ def mqtt_on_subscribe(client, userdata, mid, granted_qos): userdata.set() -def run_benchmark(num_workers: int, timeout: float, filename: str): +def run_benchmark(num_workers: int, timeout: float, filename: str, target_url: str): result_queue = multiprocessing.Queue() workers = [] for _ in range(num_workers): workers.append(multiprocessing.Process( target=independent_worker, - args=(result_queue, filename, timeout) + args=(result_queue, filename, timeout, target_url) )) for w in workers: @@ -148,7 +148,8 @@ def write_results(results, file_handle): # Latency and rtt are in ms writer.writerow( - ['id', 'http_start_time', 'http_complete_time', 'http_time', 'status_code', 'mqtt_arrive_time', 'latency', 'rtt'] + ['id', 'http_start_time', 'http_complete_time', 'http_time', 'status_code', 'mqtt_arrive_time', 'latency', + 'rtt'] ) for result in results: @@ -192,7 +193,7 @@ def main(): help='Maximum time for request sending (0 for unlimited)') parser.add_argument('--file', type=str, required=True, help='Name of the sound file to upload') - parser.add_argument('--target-url', type=str, required=False, default="https://birb.k8s.kmlabz.com/sample", + parser.add_argument('--target-url', type=str, required=False, default="https://birb.k8s.kmlabz.com/benchmark", help='The target endpoint') parser.add_argument('--inflight-timeout', type=int, required=False, default=30, @@ -235,7 +236,7 @@ def main(): print("MQTT Complete!") print("Running benchmark...") - benchmark_results = run_benchmark(args.workers, args.timeout, args.file) + benchmark_results = run_benchmark(args.workers, args.timeout, args.file, args.target_url) # Wait for inflight messages for a little total_successful_uploads = len([req for req in benchmark_results if req.upload_status_code == 200]) @@ -280,7 +281,6 @@ def main(): if not paired: print("Bruh moment: Alert arrived with an id that's not sent", returned_job.id) - total_answered += 1 # print some mini statistics