- After cloning the repository, ensure that you have checked-out submodules with
git submodule update --init.
- You can build the JNI bindings with
gradlew jar
All commands need to be run in the
tracy-jni/tracysubdirectory.
- Create a new
buildfolder undertracy-jni/tracy/profiler. - Configure the profiler using
cmake -B profiler/build -S profiler -DCMAKE_BUILD_TYPE=Release(this only needs to be done once). - Build the profiler using
cmake --build profiler/build --parallel --config Release. - The built
tracy-profilerexecutable can be found in theprofiler/build/Releasedirectory.
- At runtime, the
java.library.pathsystem property should contain a path to the native JNI libraries found intracy-jni/build/lib/main/release.
import io.github.benjaminamos.tracy.Tracy;
public class TracyTest {
public static void main(String[] args) {
// Start profiling
Tracy.startupProfiler();
// Allocate and begin zone
long handle = Tracy.allocSourceLocation(0, "Test.java", "test()", "Test!", 0);
Tracy.ZoneContext zoneContext = Tracy.zoneBegin(handle, 1);
// Do work...
// End zone
Tracy.zoneEnd(zoneContext);
// Begin new frame
Tracy.markFrame();
// Stop profiling
Tracy.shutdownProfiler();
}
}