AtomicLong/LongAdder/VarHandle counters benchmarked against the synchronized and ReentrantLock baselines from the locks module, a deterministic ABA race against a hand-rolled Treiber stack plus the AtomicStampedReference fix, and a VarHandle access-modes demo (plain/opaque/acquire-release/volatile). Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FhzLY5p6okFva3qsnsRyvM
37 lines
1.3 KiB
Bash
Executable File
37 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Regenerates every file in output/ using the same commands used to produce the ones
|
|
# committed here. Requires JDK 25 on PATH/JAVA_HOME.
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
|
|
mvn -q package
|
|
|
|
echo "--- 01: IncrementBenchmark thread-count sweep (takes a few minutes) ---"
|
|
{
|
|
echo '$ java -jar target/benchmarks.jar IncrementBenchmark -t <N> -rf text'
|
|
for t in 1 2 4 8 16 32 64; do
|
|
echo "=== threads=$t ==="
|
|
java -jar target/benchmarks.jar "IncrementBenchmark" -t "$t" -rf text -rff /tmp/jmh-atomics-$t.txt
|
|
cat "/tmp/jmh-atomics-$t.txt"
|
|
echo ""
|
|
done
|
|
} > output/01-increment-benchmark-sweep.txt
|
|
|
|
echo "--- 02: ABA problem demo ---"
|
|
{
|
|
echo '$ java -cp target/classes com.ankurm.atomics.AbaProblemDemo'
|
|
echo ""
|
|
} > output/02-aba-problem-demo.txt
|
|
java -cp target/classes com.ankurm.atomics.AbaProblemDemo >> output/02-aba-problem-demo.txt 2>&1
|
|
|
|
echo "--- 03: VarHandle access modes demo ---"
|
|
{
|
|
echo '$ java -cp target/classes com.ankurm.atomics.VarHandleAccessModesDemo'
|
|
echo ""
|
|
} > output/03-varhandle-access-modes.txt
|
|
java -cp target/classes com.ankurm.atomics.VarHandleAccessModesDemo >> output/03-varhandle-access-modes.txt 2>&1
|
|
|
|
echo "--- 04: correctness tests ---"
|
|
mvn -q test
|
|
cp target/surefire-reports/com.ankurm.atomics.CounterCorrectnessTest.txt output/04-counter-correctness.txt
|