Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically start CPU profiling with VisualVM

Tags:

java

visualvm

I'm totally new to VisualVM.

Is there a way to automatically start CPU profiling? My issue is that I start a program from Eclipse which runs for approx. 20 seconds. By the time I can open up the tab and click on CPU profiling, the app has almost finished processing.

like image 911
Jack Gibson Avatar asked Sep 27 '12 18:09

Jack Gibson


People also ask

What is self time VisualVM?

Self Time: total time spent invoking this method. If a method was called twice, the self-time will be the sum of the time spent in each call excluding internal method calls. Self Time (CPU): the same as Self Time except that only CPU execution time is considered, omitting I/O operations.

What is profiler in VisualVM?

Java VisualVM enables you to take profiler snapshots to capture the results of a profiling session. A profiler snapshot captures the results at the moment the snapshot is taken. To take a snapshot, click the Take Snapshot of Collected Results button in the toolbar while a profiling session is in progress.

How do I start VisualVM?

On a Windows system, start VisualVM by double-clicking jvisualvm.exe. You can also select VisualVM from the Start menu (if Windchill shortcuts are installed). On other systems, start VisualVM by invoking the jvisualvm script. You can also use the wt.

How use VisualVM performance testing?

Under the Local node in the Applications window, right-click the application node and choose Open to open the application tab. Click the Profiler tab in the application tab. Click Memory or CPU in the Profiler tab. When you choose a profiling task, VisualVM displays the profiling data in the Profiler tab.


1 Answers

I don't know how to automatically start profiling but I have a workaround.

You can set a breakpoint at the start of your program's main and start the program from Eclipse in debug mode. After beginning to profile in VisualVM resume your program in Eclipse.

like image 108
halex Avatar answered Oct 28 '22 11:10

halex