Search code examples
groovyjvmjprofiler

Attach JProfiler when JVM Starts or Profile Groovy Script


We have a job server that is periodically executing groovy scripts. They are not compiled.

I would like JProfiler to attach to any JVM when it starts up, record profiling information and then save the snapshot to some directory that we may look over the results at another time. Is there any way to do this?

Alternatively, I could manually start the script from inside JProfiler and get the results that way. However, it doesn't seem to be aware of Groovy scripts and I can only find a way to launch compiled Groovy code. Is there any way to launch a script and profile it?


Solution

  • You can use bin/jpenable command line utility with the --offline switch (see the output of jpenable --help) to run a pre-configured offline profiling session. That session should contain triggers for recording data and saving a snapshot.

    However, it doesn't seem to be aware of Groovy scripts

    You would have to add the groovy classes to the list of profiled classes on the "Filter Settings" tab of the session settings. However, unless the script is compiled, you would not see the method names in the call tree, so it would not be very useful.