From 50df983901ccdb9f298d036920ae1428a5741c8d Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Thu, 6 Jun 2024 22:16:22 +0200 Subject: [PATCH] wip --- scripts/ci/e2e_benchmark.py | 9 +++++++++ scripts/ci/run_benchmarks.sh | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/ci/e2e_benchmark.py b/scripts/ci/e2e_benchmark.py index 24f822782..abe37e03c 100644 --- a/scripts/ci/e2e_benchmark.py +++ b/scripts/ci/e2e_benchmark.py @@ -5,6 +5,7 @@ from collections import defaultdict import os import csv import numpy as np +import time def main(): pass @@ -25,6 +26,8 @@ def main(): url = "http://localhost:5000" + times = [] + for _ in range(10000): start = random.choice(coordinates) end = random.choice(coordinates) @@ -32,9 +35,15 @@ def main(): start_coord = f"{start[1]:.6f},{start[0]:.6f}" end_coord = f"{end[1]:.6f},{end[0]:.6f}" + start_time = time.time() response = requests.get(f"{url}/route/v1/driving/{start_coord};{end_coord}?overview=full&steps=true") + end_time = time.time() if response.status_code != 200: raise Exception(f"Error: {response.status_code} {response.text}") + times.append(end_time - start_time) + + print(f"Mean time: {np.mean(times)}") + diff --git a/scripts/ci/run_benchmarks.sh b/scripts/ci/run_benchmarks.sh index 9137b1bdd..f1613d5e6 100755 --- a/scripts/ci/run_benchmarks.sh +++ b/scripts/ci/run_benchmarks.sh @@ -47,7 +47,7 @@ function run_benchmarks_for_folder { # python3 $FOLDER/scripts/ci/process_locust_benchmark_results.py locust_results_$ALGORITHM $ALGORITHM $RESULTS_FOLDER - python3 $LOCUSTFILE_FOLDER/scripts/ci/e2e_benchmark.py + python3 $LOCUSTFILE_FOLDER/scripts/ci/e2e_benchmark.py > $RESULTS_FOLDER/e2e_$ALGORITHM.bench kill -0 $OSRM_ROUTED_PID