Skip to content

Commit

Permalink
Add simple benchmarks for osrm-* tools (#6925)
Browse files Browse the repository at this point in the history
  • Loading branch information
SiarheiFedartsou authored Jun 6, 2024
1 parent c7ee1a5 commit feeed75
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions scripts/ci/run_benchmarks.sh
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -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
Expand Down

0 comments on commit feeed75

Please sign in to comment.