Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between sampling and profiling in jVisualVM

VisualVM has two separate tabs for sampling and profiling. What is the difference between sampling and profiling in VisualVM?

like image 851
Parag Avatar asked Aug 26 '12 12:08

Parag


People also ask

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 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.

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.

Is VisualVM part of JDK?

Various optional tools, including Java VisualVM, are provided with the Java Development Kit (JDK) for retrieving different types of data about running JVM software instances. For example, most of the previously standalone tools JConsole, jstat, jinfo, jstack, and jmap are part of Java VisualVM.


1 Answers

Sampling means taking lots of thread dumps and analyzing stack traces. This is usually faster, does not require runtime changes in your bytecode (which may break it), but is also less accurate.

Profiling means instrumenting your classes and methods, so they "report" whenever they are run. This is more accurate, as it counts every invocation of instrumented method, not only those caught when the dump is done. However instrumentation means that the bytecode of your classes is changed, and this may break your program. Actually, for that reason, using profiling on large application servers (like JBoss, or WebLogic) often causes everything to die or hang.

like image 72
npe Avatar answered Sep 27 '22 17:09

npe