From c7f9fca990ca2697a89b4f82628648725a036bd4 Mon Sep 17 00:00:00 2001 From: niffy-artist2876 Date: Mon, 8 Sep 2025 20:29:56 +0530 Subject: [PATCH 1/4] Update benchmark_requests.py --- scripts/benchmark/benchmark_requests.py | 27 ++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/scripts/benchmark/benchmark_requests.py b/scripts/benchmark/benchmark_requests.py index 8098da6..ca12991 100644 --- a/scripts/benchmark/benchmark_requests.py +++ b/scripts/benchmark/benchmark_requests.py @@ -2,10 +2,14 @@ import argparse from concurrent.futures import ThreadPoolExecutor, as_completed - +from datetime import datetime +from pathlib import Path from tqdm.auto import tqdm from util import make_request +RESULTS_DIR = Path(__file__).parent/"results" +RESULTS_DIR.mkdir(exist_ok=True) + if __name__ == "__main__": """Main function to benchmark the PESUAuth API. @@ -123,14 +127,30 @@ else: success.append(0) - outfile = ( + timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") + if output: + outfile = Path(output) + else: + filename = ( + f"benchmark_[t={timestamp}]" + f"_[n={num_requests}]" + f"_[w={max_workers}]" + f"_[r={route}]" + f"_[execution_mode={'par' if parallel else 'seq'}]" + ".csv" + ) + outfile = RESULTS_DIR/filename + + outfile.parent.mkdir(parents=True, exist_ok=True) + + '''outfile = ( output if output else ( f"benchmark_[num_requests={num_requests}]_[max_workers={max_workers}]_" f"[parallel={parallel}]_[route={route}]_[timeout={timeout}].csv" ) - ) + )''' with open( outfile, @@ -139,6 +159,7 @@ f.write("status,time\n") f.writelines(f"{s},{t}\n" for s, t in zip(success, times, strict=False)) + print(f"Results saved to the following directory: {outfile}") print(f"Benchmark completed. Successful requests: {sum(success)} out of {len(success)}") print(f"Average time per request: {sum(times) / len(times):.2f} seconds") print(f"Total time taken: {sum(times):.2f} seconds") From e2471d8523c1873f455a19fd05d954c7f40f9a5b Mon Sep 17 00:00:00 2001 From: niffy-artist2876 Date: Mon, 8 Sep 2025 20:30:22 +0530 Subject: [PATCH 2/4] Revert "Update benchmark_requests.py" This reverts commit c7f9fca990ca2697a89b4f82628648725a036bd4. --- scripts/benchmark/benchmark_requests.py | 27 +++---------------------- 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/scripts/benchmark/benchmark_requests.py b/scripts/benchmark/benchmark_requests.py index ca12991..8098da6 100644 --- a/scripts/benchmark/benchmark_requests.py +++ b/scripts/benchmark/benchmark_requests.py @@ -2,14 +2,10 @@ import argparse from concurrent.futures import ThreadPoolExecutor, as_completed -from datetime import datetime -from pathlib import Path + from tqdm.auto import tqdm from util import make_request -RESULTS_DIR = Path(__file__).parent/"results" -RESULTS_DIR.mkdir(exist_ok=True) - if __name__ == "__main__": """Main function to benchmark the PESUAuth API. @@ -127,30 +123,14 @@ else: success.append(0) - timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") - if output: - outfile = Path(output) - else: - filename = ( - f"benchmark_[t={timestamp}]" - f"_[n={num_requests}]" - f"_[w={max_workers}]" - f"_[r={route}]" - f"_[execution_mode={'par' if parallel else 'seq'}]" - ".csv" - ) - outfile = RESULTS_DIR/filename - - outfile.parent.mkdir(parents=True, exist_ok=True) - - '''outfile = ( + outfile = ( output if output else ( f"benchmark_[num_requests={num_requests}]_[max_workers={max_workers}]_" f"[parallel={parallel}]_[route={route}]_[timeout={timeout}].csv" ) - )''' + ) with open( outfile, @@ -159,7 +139,6 @@ f.write("status,time\n") f.writelines(f"{s},{t}\n" for s, t in zip(success, times, strict=False)) - print(f"Results saved to the following directory: {outfile}") print(f"Benchmark completed. Successful requests: {sum(success)} out of {len(success)}") print(f"Average time per request: {sum(times) / len(times):.2f} seconds") print(f"Total time taken: {sum(times):.2f} seconds") From 50cc3218d9d942bf6443bc1be93b2dc363d0d378 Mon Sep 17 00:00:00 2001 From: niffy-artist2876 Date: Mon, 8 Sep 2025 21:36:13 +0530 Subject: [PATCH 3/4] Update benchmark_requests.py --- scripts/benchmark/benchmark_requests.py | 26 +++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/scripts/benchmark/benchmark_requests.py b/scripts/benchmark/benchmark_requests.py index 8098da6..7a77a47 100644 --- a/scripts/benchmark/benchmark_requests.py +++ b/scripts/benchmark/benchmark_requests.py @@ -2,10 +2,15 @@ import argparse from concurrent.futures import ThreadPoolExecutor, as_completed +from datetime import datetime +from pathlib import Path from tqdm.auto import tqdm from util import make_request +RESULTS_DIR = Path(__file__).parent / "results" +RESULTS_DIR.mkdir(exist_ok=True) + if __name__ == "__main__": """Main function to benchmark the PESUAuth API. @@ -123,14 +128,30 @@ else: success.append(0) - outfile = ( + timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") + if output: + outfile = Path(output) + else: + filename = ( + f"benchmark_[t={timestamp}]" + f"_[n={num_requests}]" + f"_[w={max_workers}]" + f"_[r={route}]" + f"_[execution_mode={'par' if parallel else 'seq'}]" + ".csv" + ) + outfile = RESULTS_DIR / filename + + outfile.parent.mkdir(parents=True, exist_ok=True) + + """outfile = ( output if output else ( f"benchmark_[num_requests={num_requests}]_[max_workers={max_workers}]_" f"[parallel={parallel}]_[route={route}]_[timeout={timeout}].csv" ) - ) + )""" with open( outfile, @@ -139,6 +160,7 @@ f.write("status,time\n") f.writelines(f"{s},{t}\n" for s, t in zip(success, times, strict=False)) + print(f"Results saved to the following directory: {outfile}") print(f"Benchmark completed. Successful requests: {sum(success)} out of {len(success)}") print(f"Average time per request: {sum(times) / len(times):.2f} seconds") print(f"Total time taken: {sum(times):.2f} seconds") From 5bd15b28fa19f903b101bb43969b3f6edb4248b3 Mon Sep 17 00:00:00 2001 From: niffy-artist2876 Date: Sun, 5 Oct 2025 18:32:48 +0530 Subject: [PATCH 4/4] Update benchmark_requests.py made all the required changes to benchmark_requests.py, had to delay work on this because of ISA --- scripts/benchmark/benchmark_requests.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/scripts/benchmark/benchmark_requests.py b/scripts/benchmark/benchmark_requests.py index 7a77a47..63b1e3d 100644 --- a/scripts/benchmark/benchmark_requests.py +++ b/scripts/benchmark/benchmark_requests.py @@ -8,9 +8,6 @@ from tqdm.auto import tqdm from util import make_request -RESULTS_DIR = Path(__file__).parent / "results" -RESULTS_DIR.mkdir(exist_ok=True) - if __name__ == "__main__": """Main function to benchmark the PESUAuth API. @@ -129,6 +126,11 @@ success.append(0) timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") + + results_dir = Path("benchmark") / "results" + if not results_dir.exists(): + results_dir.mkdir(parents=True, exist_ok=True) + if output: outfile = Path(output) else: @@ -140,18 +142,11 @@ f"_[execution_mode={'par' if parallel else 'seq'}]" ".csv" ) - outfile = RESULTS_DIR / filename + outfile = results_dir / filename - outfile.parent.mkdir(parents=True, exist_ok=True) - - """outfile = ( - output - if output - else ( - f"benchmark_[num_requests={num_requests}]_[max_workers={max_workers}]_" - f"[parallel={parallel}]_[route={route}]_[timeout={timeout}].csv" - ) - )""" + parent_dir = outfile.parent + if not parent_dir.exists(): + parent_dir.mkdir(parents=True, exist_ok=True) with open( outfile, @@ -160,7 +155,7 @@ f.write("status,time\n") f.writelines(f"{s},{t}\n" for s, t in zip(success, times, strict=False)) - print(f"Results saved to the following directory: {outfile}") + print(f"Results saved to: {outfile}") print(f"Benchmark completed. Successful requests: {sum(success)} out of {len(success)}") print(f"Average time per request: {sum(times) / len(times):.2f} seconds") print(f"Total time taken: {sum(times):.2f} seconds")