Skip to content

Instantly share code, notes, and snippets.

@bogovicj
Last active February 25, 2026 19:34
Show Gist options
  • Select an option

  • Save bogovicj/4a1c4c620aaf795718114eaaa49dfd9b to your computer and use it in GitHub Desktop.

Select an option

Save bogovicj/4a1c4c620aaf795718114eaaa49dfd9b to your computer and use it in GitHub Desktop.
Run n5 block read benchmarks for a set of commits
#!/usr/bin/env bash
## Which benchmark to run
## BlockReadWriteBenchmarks : benchmarks file reading and decoding
## BlockCodecBenchmarks" : benchmarks decoding only
benchmark="BlockCodecBenchmarks"
## Benchmark parameters
dataTypes="int32"
fillType="random"
compressionTypes="raw,gzip,blosc,zstd"
## Commits
declare -A commits
declare -A univcommits
declare -A descriptions
commits["master"]="0b6da3de9993e99c696633f8c4b64c898b54b184"
univcommits["master"]="development"
descriptions["master"]="master"
commits["a"]="bfa73fb2962025b8d2f32573776e0ce2a9bfe1aa"
univcommits["a"]="development"
descriptions["a"]="materialize"
commits["b"]="3201e6a08bcf42f6d2d1f529c6e5dc949b251d05"
univcommits["b"]="development"
descriptions["b"]="materialize, avoid IOUtils"
commits["3.5.1"]=""
univcommits["3.5.1"]="benchmark/n5-3.5.1"
descriptions["3.5.1"]="n5-3.5.1"
setup() {
if [ ! -d "n5" ]; then
git clone git@github.com:saalfeldlab/n5.git
fi
if [ ! -d "n5-universe" ]; then
git clone git@github.com:saalfeldlab/n5-universe.git
fi
}
buildAndRunBenchmark() {
key="$1"
commit="${commits[$key]}"
univcommit="${univcommits[$key]}"
desc="${descriptions[$key]}"
## checkout and build
n5_version_arg=""
if [[ ! -z "$commit" ]]; then
echo "build n5"
git -C n5 checkout $commit
mvn -f n5/ clean install -DskipTests > build-n5 2> build-n5
n5_version=$(mvn -f n5/ help:evaluate -Dexpression=project.version -q -DforceStdout)
n5_version_arg="-Dn5.version=$n5_version"
fi
## Build n5-universe with the n5 version
git -C n5-universe checkout $univcommit
mvn -f n5-universe/ clean package -DskipTests -Pbenchmarks $n5_version_arg > build-n5-universe 2> build-n5-universe
java -jar n5-universe/target/microbenchmarks.jar $benchmark \
-p dataType=$dataTypes -p fillType=$fillType -p compressionType=$compressionTypes \
-e writeBenchmark >> results
echo "$key $commit $desc" >> results
echo "#####" >> results
}
setup
for key in "${!commits[@]}";
do
echo $key
buildAndRunBenchmark $key
echo "------------------"
echo "------------------"
echo "------------------"
done
grep "^$benchmark" -A 2 results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment