From feeed75cf1529288b560150988a50997df1cb057 Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Thu, 6 Jun 2024 21:01:34 +0200 Subject: [PATCH] Add simple benchmarks for osrm-* tools (#6925) --- scripts/ci/run_benchmarks.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/scripts/ci/run_benchmarks.sh b/scripts/ci/run_benchmarks.sh index 51ced3d53..7b78ed66c 100755 --- a/scripts/ci/run_benchmarks.sh +++ b/scripts/ci/run_benchmarks.sh @@ -1,6 +1,18 @@ #!/bin/bash set -eou pipefail +function measure_peak_ram_and_time { + COMMAND=$1 + OUTPUT_FILE=$2 + + OUTPUT=$(/usr/bin/time -f "%e %M" $COMMAND 2>&1 | tail -n 1) + + TIME=$(echo $OUTPUT | awk '{print $1}') + PEAK_RAM_KB=$(echo $OUTPUT | awk '{print $2}') + PEAK_RAM_MB=$(echo "scale=2; $PEAK_RAM_KB / 1024" | bc) + echo "Time: ${TIME}s Peak RAM: ${PEAK_RAM_MB}MB" > $OUTPUT_FILE +} + function run_benchmarks_for_folder { echo "Running benchmarks for $1" @@ -23,10 +35,11 @@ function run_benchmarks_for_folder { BINARIES_FOLDER="$FOLDER/build" cp ~/data.osm.pbf $FOLDER - $BINARIES_FOLDER/osrm-extract -p $FOLDER/profiles/car.lua $FOLDER/data.osm.pbf - $BINARIES_FOLDER/osrm-partition $FOLDER/data.osrm - $BINARIES_FOLDER/osrm-customize $FOLDER/data.osrm - $BINARIES_FOLDER/osrm-contract $FOLDER/data.osrm + + measure_peak_ram_and_time "$BINARIES_FOLDER/osrm-extract -p $FOLDER/profiles/car.lua $FOLDER/data.osm.pbf" "$RESULTS_FOLDER/osrm_extract.bench" + measure_peak_ram_and_time "$BINARIES_FOLDER/osrm-partition $FOLDER/data.osrm" "$RESULTS_FOLDER/osrm_partition.bench" + measure_peak_ram_and_time "$BINARIES_FOLDER/osrm-customize $FOLDER/data.osrm" "$RESULTS_FOLDER/osrm_customize.bench" + measure_peak_ram_and_time "$BINARIES_FOLDER/osrm-contract $FOLDER/data.osrm" "$RESULTS_FOLDER/osrm_contract.bench" if [ -f "$FOLDER/scripts/ci/locustfile.py" ]; then for ALGORITHM in mld ch; do