#!/bin/bash

testJDK() {
	echo -----------------------
	echo Testing with $1
	export JAVA_HOME=$HOME/Downloads/$1
	$JAVA_HOME/bin/java -version

	export TEST_FOLDER=jdk-8349364/src/main/java
	echo Compiling
	$JAVA_HOME/bin/javac $TEST_FOLDER/Test1.java 
	$JAVA_HOME/bin/javac $TEST_FOLDER/Test2.java 
	echo Compiled

	echo $JAVA_HOME/bin/java -cp $TEST_FOLDER -XX:TieredStopAtLevel=1 Test1
	time $JAVA_HOME/bin/java -cp $TEST_FOLDER -XX:TieredStopAtLevel=1 Test1
	echo $JAVA_HOME/bin/java -cp $TEST_FOLDER -XX:TieredStopAtLevel=2 Test1
	time $JAVA_HOME/bin/java -cp $TEST_FOLDER -XX:TieredStopAtLevel=2 Test1
	echo $JAVA_HOME/bin/java -cp $TEST_FOLDER -XX:TieredStopAtLevel=3 Test1
	time $JAVA_HOME/bin/java -cp $TEST_FOLDER -XX:TieredStopAtLevel=3 Test1
	echo $JAVA_HOME/bin/java -cp $TEST_FOLDER -XX:TieredStopAtLevel=4 Test1
	time $JAVA_HOME/bin/java -cp $TEST_FOLDER -XX:TieredStopAtLevel=4 Test1

	echo $JAVA_HOME/bin/java -cp $TEST_FOLDER -XX:TieredStopAtLevel=1 Test2
	time $JAVA_HOME/bin/java -cp $TEST_FOLDER -XX:TieredStopAtLevel=1 Test2
	echo $JAVA_HOME/bin/java -cp $TEST_FOLDER -XX:TieredStopAtLevel=2 Test2
	time $JAVA_HOME/bin/java -cp $TEST_FOLDER -XX:TieredStopAtLevel=2 Test2
	echo $JAVA_HOME/bin/java -cp $TEST_FOLDER -XX:TieredStopAtLevel=3 Test2
	time $JAVA_HOME/bin/java -cp $TEST_FOLDER -XX:TieredStopAtLevel=3 Test2
	echo $JAVA_HOME/bin/java -cp $TEST_FOLDER -XX:TieredStopAtLevel=4 Test2
	time $JAVA_HOME/bin/java -cp $TEST_FOLDER -XX:TieredStopAtLevel=4 Test2
}

jdks=(
#jdk1.8.0_391
#jdk-11.0.21
#jdk-17.0.2  
#jdk-17.0.10
#jdk-17.0.11/fastdebug
jdk-17.0.12
#jdk-21.0.2	
#jdk-21.0.5	
jdk-21.0.6	
jdk-23.0.1	
#openjdk-8u402-b06
#openjdk-11.0.22+7  
#openjdk-17.0.10+7  
#openjdk-21.0.2	
#openjdk-22
#openjdk-23
#openjdk-24
)

for i in ${jdks[@]}
do
	testJDK $i
done
