Api agent

Questions about YourKit Java Profiler
Post Reply
Gustavo Woltmann
Posts: 2
Joined: Wed Feb 24, 2016 6:36 pm

Api agent

Post by Gustavo Woltmann »

Is there a way to start and stop profiling from inside the profiled application itself programmatically ?
I'd like to profile a section of code only when certain application conditions are met, i.e. in app code I would like to make a temporary change and have something like this:

try {
if (app conditions) {
Profiler.startCpuProfiling();
}
....
} finally {
Profiler.captureSnapshot("snapshotfile");
}
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Api agent

Post by Anton Katilin »

Yes. Please use the profiler API, class com.yourkit.api.Controller:

https://www.yourkit.com/docs/java/help/api.jsp

As an alternate solution, please consider triggers on method invocation:
https://www.yourkit.com/docs/java/help/triggers.jsp
Post Reply