Projects / Profiler agent / Before you start
Before you start
Install JDK 21 or newer and check it:
java -version
javac -version
Every listing and command in this project was run with JDK 21 on x86-64 Linux. We used only the JDK itself: no Maven, no Gradle, no libraries. Each phase is its own folder (d1, d2, and so on), so an older version stays next to a newer one. The layout of each folder is the same:
Workload.java the program we will profile
src/prof/*.java the profiler (package prof)
manifest.txt tells the JVM which class is the agent
build.sh compiles everything and builds agent.jar
The program we profile is written so that we know the right answer. It has three methods that burn CPU for a fixed time in every round: hot for 600 ms, warm for 300 ms and cold for 100 ms. So the truth is 60%, 30% and 10%. A profiler is only worth trusting when you have caught it giving a right answer on a case where you knew the answer.