Files

26 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Short JMH run: INDICATIVE only. One fork, 3 x 1s warmup, 5 x 2s measurement per cell.
# On a shared 2-vCPU sandbox the absolute numbers move 10-30% between runs; read the ORDER and
# the SHAPE (who collapses with more threads), not the third digit.
set -euo pipefail
cd "$(dirname "$0")/.."
mkdir -p output
mvn -B -q -T1 compile
mvn -B -q dependency:build-classpath -Dmdep.outputFile=target/cp.txt
CP="target/classes:$(cat target/cp.txt)"
J="java -cp $CP org.openjdk.jmh.Main LruBenchmark -f 1 -wi 3 -w 1 -i 5 -r 2 -tu us"
{
echo "JMH 1.37 / $(java -version 2>&1 | grep -v Picked | head -1)"
echo "cores=$(nproc) loadavg-at-start=$(cut -d' ' -f1-3 /proc/loadavg) (shared sandbox: INDICATIVE)"
echo "workload: get; on miss put. Keys uniform over 2048, capacity 1024. ops/microsecond, higher is better."
echo
echo "### 1 thread, all implementations"
$J -t 1 2>&1 | grep -E '^LruBenchmark|^Benchmark'
for t in 2 4; do
echo
echo "### $t threads, thread-safe implementations only"
$J -t $t -p "impl=synchronizedMap(LinkedHashMap),synchronized,reentrantlock,striped16,striped16-lowbits,caffeine" 2>&1 | grep -E '^LruBenchmark|^Benchmark'
done
} > output/10-jmh-indicative.txt
cat output/10-jmh-indicative.txt