Skip to content

Commit

Permalink
Setup periodic benchmarks
Browse files Browse the repository at this point in the history
If the benchmark build runs with special flag set (PERIODIC_BUILD) the measurement time instead of the git commit
time is used as reference time for the resulting benchmark result file
  • Loading branch information
easbar committed Dec 28, 2019
1 parent 9913296 commit dcf4389
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ run_measurement:
- export BENCHMARK_BIG_MAP_NAME=germany-190101.osm.pbf
- export BENCHMARK_BIG_MAP_URL=http://download.geofabrik.de/europe/${BENCHMARK_BIG_MAP_NAME}
- export BENCHMARK_BIG_MAP_PATH=${BENCHMARK_DIR}osm/${BENCHMARK_BIG_MAP_NAME}
- export USE_MEASUREMENT_TIME_AS_REF_TIME=${PERIODIC_BUILD:-false}
- mkdir -p ${BENCHMARK_DIR}osm
- mvn $MAVEN_CLI_OPTS package -DskipTests -pl tools -am
- chmod +x -R benchmark
- benchmark/download_map.sh $BENCHMARK_SMALL_MAP_URL $BENCHMARK_SMALL_MAP_PATH
- benchmark/download_map.sh $BENCHMARK_BIG_MAP_URL $BENCHMARK_BIG_MAP_PATH
- benchmark/benchmark.sh $BENCHMARK_DIR $BENCHMARK_RESULT_DIR $BENCHMARK_SMALL_MAP_PATH $BENCHMARK_BIG_MAP_PATH
- benchmark/benchmark.sh $BENCHMARK_DIR $BENCHMARK_RESULT_DIR $BENCHMARK_SMALL_MAP_PATH $BENCHMARK_BIG_MAP_PATH $USE_MEASUREMENT_TIME_AS_REF_TIME
- benchmark/post_benchmark.sh $BENCHMARK_RESULT_DIR $BENCHMARK_DB_USER $BENCHMARK_DB_PWD $BENCHMARK_DB_URL
- rm -rf $BENCHMARK_RESULT_DIR
11 changes: 8 additions & 3 deletions benchmark/benchmark.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/bin/bash
# usage:
# benchmark/benchmark.sh <data_dir> <results_dir> <small_osm_map_path> <big_osm_map_path>
# benchmark/benchmark.sh <data_dir> <results_dir> <small_osm_map_path> <big_osm_map_path> <use_measurement_time_as_ref_time>
#
# where:
# <data_dir> = base directory used to store results
# <results_dir> = name of directory where results of this run are stored (inside <data_dir>)
# <small_osm_map_path> = path to osm map the measurement is run on for slow measurements
# <big_osm_map_path> = path to osm map the measurement is run on for fast measurements
# <use_measurement_time_as_ref_time> = true/false, false by default, meaning the git commit time will be used as reference

# make this script exit if a command fails, a variable is missing etc.
set -euo pipefail
Expand All @@ -15,6 +16,7 @@ defaultDataDir=measurements/
defaultSingleResultsDir=measurements/results/$(date '+%d-%m-%Y-%s%N')/
defaultSmallMap=core/files/andorra.osm.pbf
defaultBigMap=core/files/andorra.osm.pbf
defaultUseMeasurementTimeAsRefTime=false

# this is the directory where we read/write data from/to
DATA_DIR=${1:-$defaultDataDir}
Expand All @@ -23,6 +25,7 @@ TMP_DIR=${DATA_DIR}tmp/
SINGLE_RESULTS_DIR=${2:-$defaultSingleResultsDir}
SMALL_OSM_MAP=${3:-$defaultSmallMap}
BIG_OSM_MAP=${4:-$defaultBigMap}
USE_MEASUREMENT_TIME_AS_REF_TIME=${5:-$defaultUseMeasurementTimeAsRefTime}

# create directories
mkdir -p ${DATA_DIR}
Expand All @@ -48,7 +51,8 @@ graph.location=${TMP_DIR}measurement-small-gh \
prepare.min_network_size=10000 \
prepare.min_oneway_network_size=10000 \
measurement.json=true \
measurement.count=5000
measurement.count=5000 \
measurement.useMeasurementTimeAsRefTime=${USE_MEASUREMENT_TIME_AS_REF_TIME}

# 2 - big map: node-based CH + landmarks
java -cp tools/target/graphhopper-tools-*-jar-with-dependencies.jar com.graphhopper.tools.Measurement \
Expand All @@ -67,4 +71,5 @@ graph.location=${TMP_DIR}measurement-big-gh \
prepare.min_network_size=10000 \
prepare.min_oneway_network_size=10000 \
measurement.json=true \
measurement.count=5000
measurement.count=5000 \
measurement.useMeasurementTimeAsRefTime=${USE_MEASUREMENT_TIME_AS_REF_TIME}
17 changes: 14 additions & 3 deletions tools/src/main/java/com/graphhopper/tools/Measurement.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ protected DataReader importData() throws IOException {
writeSummary(summaryLocation, propLocation);
}
if (useJson) {
storeJson(propLocation);
storeJson(propLocation, args.getBool("measurement.useMeasurementTimeAsRefTime", false));
} else {
storeProperties(propLocation);
}
Expand Down Expand Up @@ -595,10 +595,10 @@ void put(String key, Object val) {
properties.put(key, val);
}

private void storeJson(String jsonLocation) {
private void storeJson(String jsonLocation, boolean useMeasurementTimeAsRefTime) {
logger.info("storing measurement json in " + jsonLocation);
Map<String, Object> result = new HashMap<>();
Map<String, String> gitInfoMap = new HashMap<>();
// add git info if available
if (Constants.GIT_INFO != null) {
properties.remove("gh.gitinfo");
gitInfoMap.put("commitHash", Constants.GIT_INFO.getCommitHash());
Expand All @@ -607,6 +607,17 @@ private void storeJson(String jsonLocation) {
gitInfoMap.put("branch", Constants.GIT_INFO.getBranch());
gitInfoMap.put("dirty", String.valueOf(Constants.GIT_INFO.isDirty()));
}
Map<String, Object> result = new HashMap<>();
// add measurement time, use same format as git commit time
String measurementTime = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ssZ").format(new Date());
result.put("measurementTime", measurementTime);
// set ref time, this is either the git commit time or the measurement time
if (Constants.GIT_INFO != null && !useMeasurementTimeAsRefTime) {
result.put("refTime", Constants.GIT_INFO.getCommitTime());
} else {
result.put("refTime", measurementTime);
}
result.put("periodicBuild", useMeasurementTimeAsRefTime);
result.put("gitinfo", gitInfoMap);
result.put("metrics", properties);
try {
Expand Down

0 comments on commit dcf4389

Please sign in to comment.