Implement end-to-end benchmark
This commit is contained in:
parent
54bf165d22
commit
778560d325
@ -1,18 +1,36 @@
|
||||
from locust import HttpUser, TaskSet, task, between
|
||||
import csv
|
||||
import random
|
||||
|
||||
class OSRMTasks(TaskSet):
|
||||
def on_start(self):
|
||||
random.seed(42)
|
||||
|
||||
self.coordinates = []
|
||||
with open('~/gps_traces.csv', 'r') as file:
|
||||
reader = csv.DictReader(file)
|
||||
for row in reader:
|
||||
self.coordinates.append((row['Latitude'], row['Longitude']))
|
||||
|
||||
@task
|
||||
def get_route(self):
|
||||
start = "13.388860,52.517037"
|
||||
end = "13.397634,52.529407"
|
||||
start = random.choice(self.coordinates)
|
||||
end = random.choice(self.coordinates)
|
||||
|
||||
self.client.get(f"/route/v1/driving/{start};{end}?overview=full&steps=true")
|
||||
start_coord = f"{start[1]},{start[0]}"
|
||||
end_coord = f"{end[1]},{end[0]}"
|
||||
|
||||
self.client.get(f"/route/v1/driving/{start_coord};{end_coord}?overview=full&steps=true")
|
||||
|
||||
@task
|
||||
def get_table(self):
|
||||
coordinates = "13.388860,52.517037;13.397634,52.529407;13.428555,52.523219"
|
||||
self.client.get(f"/table/v1/driving/{coordinates}")
|
||||
num_coords = random.randint(3, 500)
|
||||
selected_coords = random.sample(self.coordinates, num_coords)
|
||||
coords_str = ";".join([f"{coord[1]},{coord[0]}" for coord in selected_coords])
|
||||
|
||||
self.client.get(f"/table/v1/driving/{coords_str}")
|
||||
|
||||
class OSRMUser(HttpUser):
|
||||
tasks = [OSRMTasks]
|
||||
wait_time = between(1, 5)
|
||||
wait_time = between(0.01, 0.1)
|
||||
|
||||
|
@ -13,13 +13,14 @@ function run_benchmarks_for_folder {
|
||||
|
||||
# ./$BENCHMARKS_FOLDER/match-bench "./$FOLDER/test/data/mld/monaco.osrm" mld > "$RESULTS_FOLDER/match_mld.bench"
|
||||
# ./$BENCHMARKS_FOLDER/match-bench "./$FOLDER/test/data/ch/monaco.osrm" ch > "$RESULTS_FOLDER/match_ch.bench"
|
||||
# ./$BENCHMARKS_FOLDER/route-bench "./$FOLDER/test/data/mld/monaco.osrm" mld > "$RESULTS_FOLDER/route_mld.bench" || true # TODO: remove `true` when this benchmark will be merged to master
|
||||
# ./$BENCHMARKS_FOLDER/route-bench "./$FOLDER/test/data/ch/monaco.osrm" ch > "$RESULTS_FOLDER/route_ch.bench" || true # TODO: remove `true` when this benchmark will be merged to master
|
||||
# ./$BENCHMARKS_FOLDER/route-bench "./$FOLDER/test/data/mld/monaco.osrm" mld > "$RESULTS_FOLDER/route_mld.bench"
|
||||
# ./$BENCHMARKS_FOLDER/route-bench "./$FOLDER/test/data/ch/monaco.osrm" ch > "$RESULTS_FOLDER/route_ch.bench"
|
||||
# ./$BENCHMARKS_FOLDER/alias-bench > "$RESULTS_FOLDER/alias.bench"
|
||||
# ./$BENCHMARKS_FOLDER/json-render-bench "./$FOLDER/src/benchmarks/portugal_to_korea.json" > "$RESULTS_FOLDER/json-render.bench"
|
||||
# ./$BENCHMARKS_FOLDER/packedvector-bench > "$RESULTS_FOLDER/packedvector.bench"
|
||||
# ./$BENCHMARKS_FOLDER/rtree-bench "./$FOLDER/test/data/monaco.osrm.ramIndex" "./$FOLDER/test/data/monaco.osrm.fileIndex" "./$FOLDER/test/data/monaco.osrm.nbg_nodes" > "$RESULTS_FOLDER/rtree.bench"
|
||||
|
||||
# TODO: CH
|
||||
BINARIES_FOLDER="$FOLDER/build"
|
||||
echo "PWD: $FOLDER"
|
||||
cp ~/data.osm.pbf $FOLDER
|
||||
@ -30,20 +31,22 @@ function run_benchmarks_for_folder {
|
||||
OSRM_ROUTED_PID=$!
|
||||
|
||||
# TODO: save results
|
||||
curl --retry-delay 3 --retry 10 --retry-all-errors "http://127.0.0.1:5000/route/v1/driving/13.388860,52.517037;13.385983,52.496891?steps=true"
|
||||
locust -f $FOLDER/locustfile.py --headless --users 10 --spawn-rate 1 --host http://localhost:5000 --run-time 1m --csv=results
|
||||
if [ -f "$FOLDER/locustfile.py" ]; then
|
||||
curl --retry-delay 3 --retry 10 --retry-all-errors "http://127.0.0.1:5000/route/v1/driving/13.388860,52.517037;13.385983,52.496891?steps=true"
|
||||
locust -f $FOLDER/locustfile.py --headless --users 10 --spawn-rate 1 --host http://localhost:5000 --run-time 1m --csv=results
|
||||
|
||||
echo "STATS: "
|
||||
cat results_stats.csv
|
||||
echo "FAILURES: "
|
||||
cat results_failures.csv
|
||||
echo "EXCEPTIONS: "
|
||||
cat results_exceptions.csv
|
||||
echo "STATS HISTORY: "
|
||||
cat results_stats_history.csv
|
||||
echo "STATS: "
|
||||
cat results_stats.csv
|
||||
echo "FAILURES: "
|
||||
cat results_failures.csv
|
||||
echo "EXCEPTIONS: "
|
||||
cat results_exceptions.csv
|
||||
echo "STATS HISTORY: "
|
||||
cat results_stats_history.csv
|
||||
|
||||
|
||||
kill -0 $OSRM_ROUTED_PID
|
||||
kill -0 $OSRM_ROUTED_PID
|
||||
fi
|
||||
}
|
||||
|
||||
run_benchmarks_for_folder $1 "${1}_results"
|
||||
|
Loading…
Reference in New Issue
Block a user