1 #!/bin/bash
 2 
 3 JDK=$1
 4 OPTIONS=${@:2}
 5 
 6 JAVA_HOME=${JDK}/jdk mvn clean package || exit 1
 7 
 8 iter=20
 9 forks=2
10 file=jmh.out
11 
12 params=(-p stackDepth=5 -p paramCount=3)
13 
14 run_benchmark() {
15 	local benchmark=$1
16 	local perflevels=${@:2}
17 
18 	local last=0
19 
20 	for perf in ${perflevels[@]}; do
21 		echo
22 		echo "======================================================"
23 		echo "benchmark=$benchmark OPTIONS=$OPTIONS perf=$perf "
24 		echo "------------------------------------------------------"
25 		echo
26 
27 		$JDK/jdk/bin/java --add-opens java.base/java.io=ALL-UNNAMED -XX:+UnlockDiagnosticVMOptions $OPTIONS -XX:ContPerfTest=$perf -jar target/benchmarks.jar $benchmark -foe true -f $forks -i $iter -v SILENT -rf text -rff $file ${params[@]} && cat $file
28 		
29 		res=$(cat $file| tail -1 | awk '{ print $6 }')
30 		echo
31 		delta=$(echo "$res - $last" | bc)
32 		last=$res
33 		echo "Delta: $delta"
34 	done
35 	rm $file
36 	echo
37 	echo
38 }
39 
40 run_benchmark baseline 1000
41 run_benchmark yieldAndContinue 1000
42 
43 # run_benchmark justYield    5 10 15 20 25 30
44 # run_benchmark justContinue 105 110 112 115 120 125 130