Category: jprofiler

CPU profiling: Sampling and instrumentation

In this screencast, I explain the two modes of CPU profiling, sampling and instrumentation and how they are activated in the JProfiler GUI. Choosing and understanding these modes is important for getting good results.

Methods statistics and exceptional method runs

In the screencast below, I explain how to analyze exceptionally slow invocations of frequently invoked methods. By using the method statistics and exceptional method run features in JProfiler, the slowest invocations are shown separately in the call tree.

The test class that is profiled in this screen cast is given below:

import java.util.Random;

public class MethodStatisticsTest {

private static Random random = new Random(0);

public static void main(String[] args) {
while (true) {

private static void doCriticalTask() {
if (random.nextInt(1000) % 999 == 0) {
} else {

private static void implOne() {
for (int i = 0; i < 100000; i++) {

private static void implTwo() {
for (int i = 0; i < 1000; i++) {

Market study for multicore software development tools featuring JProfiler

The Fraunhofer IAO has published a study on multi-core software development tools that features JProfiler.

The study can be viewed free of charge, but requires a registration for download. The abstract of the study is as follows:

To unlock the performance potentials of current processors, software has to be adapted for execution on multiple cores; it has to be parallelized. This requires the identification of parts that can run concurrently, adaptation of these parts, testing of the changes for correctness and the coordination of the concurrently running parts with regard to performance and scalability.

In this study Fraunhofer IAO characterizes the challenges of software development for multicore processors and presents tools that assist in the process. Profilers reveal parallelizable parts, programming languages and libraries help with the correct introduction of parallelism, debuggers show errors during parallel execution and tuners help achieving maximum parallel performance.

JProfiler’s extensive support for locking analysis introduced in 6.0 is an important tool for this kinds of analysis.

Offline profiling and triggers

In the screencast below, I explain how to automate profiling with offline profiling and triggers, so that you do not have to use the JProfiler GUI for profiling and can analyze profiling results later on.

Locking graphs in JProfiler

In the screencast below, I present some of the features in the locking graphs that have been introduced in JProfiler 6.

The test class that is profiled in this screen cast is given below:

public class MonitorTest {

// The only monitor that all threads are blocking or waiting on
private static final MonitorTest monitor = new MonitorTest();

public static void main(String[] args) throws InterruptedException {

// All threads execute this runnable, each thread acquires the
// monitor, works for 3 seconds and then waits on the monitor
Runnable runnable = new Runnable() {
public void run() {
synchronized (monitor) {
try {
// Instead of doing any real work, the thread just
// sleeps for 3 second
} catch (InterruptedException e) {


// 3 threads are started with an offset of 500 ms
new Thread(runnable, "Test Thread 1").start();
new Thread(runnable, "Test Thread 2").start();
new Thread(runnable, "Test Thread 3").start();

// After 20 seconds, all threads are woken up and the test class
// terminates
synchronized (monitor) {