Skip to content

Commit

Permalink
Add benchmark.zsh driver script
Browse files Browse the repository at this point in the history
  • Loading branch information
msteindorfer committed Oct 2, 2023
1 parent c58a40d commit 1c338f1
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
47 changes: 47 additions & 0 deletions benchmark.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/zsh

# Usage:
# `./benchmark.zsh` ......... benchmark run-time performance and memory footprint
# `./benchmark.zsh time` .... benchmark run-time performance only
# `./benchmark.zsh space` ... benchmark memory footprint only

set -euo pipefail

benchmark_selector=${1:-}

export PARAM_SIZE="8,2048,1048576"
export PARAM_VALUE_FACTORY="VF_CAPSULE,VF_SCALA,VF_CLOJURE"
export MEMORY_MEASURER_AGENT="$(./gradlew memoryMeasurerLocation --quiet)"

export JMH_JAR=`find $(pwd) -name "*-jmh.jar"`

####
# MEASURE RUNTIMES
##################################

if [[ -z "$benchmark_selector" || "$benchmark_selector" == "time" ]]; then
java -jar $JMH_JAR \
"JmhSetBenchmarks.time(Lookup$|Insert$|Remove$|Iteration|EqualsWorstCase)$" \
-f 1 -i 5 -wi 5 \
-p producer=PURE_INTEGER \
-p size=$PARAM_SIZE \
-p valueFactoryFactory=$PARAM_VALUE_FACTORY \
-rf text -rff log-jmh-persistent-collections-time.txt

# further benchmarks: SubsetOf|(Union|Subtract|Intersect)RealDuplicate
fi

###
# MEASURE MEMORY FOOTPRINT
#################################

if [[ -z "$benchmark_selector" || "$benchmark_selector" == "space" ]]; then
java -javaagent:$MEMORY_MEASURER_AGENT -jar $JMH_JAR \
"JmhSetBenchmarks.footprint$" \
-f 1 -bm ss \
-p producer=PURE_INTEGER \
-p size=$PARAM_SIZE \
-p valueFactoryFactory=$PARAM_VALUE_FACTORY \
-prof io.usethesource.capsule.jmh.profiler.MemoryFootprintProfiler \
-rf text -rff log-jmh-persistent-collections-space.txt
fi
5 changes: 5 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ repositories {
}
}

tasks.register("memoryMeasurerLocation") {
val jarFile = configurations.jmh.get().files.first { it.name.contains("memory-measurer") }
println(jarFile.toString())
}

java {
withSourcesJar()

Expand Down

0 comments on commit 1c338f1

Please sign in to comment.