Skip to content
Advertisement

Checking Run time in IntelliJ IDEA Ultimate

Can I use InteliJ Ultimate’s profiler to see how long it takes for a method to be executed?

Advertisement

Answer

Two particularly helpful tools for examining the program at runtime are the debugger and profilers.

The debugger is very precise and gives you full and granular control over the execution of the program, which allows you to reproduce intricate failure conditions.

The profiler, on the other hand, offers a bird’s eye view of arbitrarily large execution chunks. It does not interfere with the running program, nor does it provide granular data as the debugger does. However, it can collect valuable information.

Java Flight Recorder – a standard profiling tool shipped as part of the JDK.

Async Profiler – a very accurate profiler that can also collect native call and memory allocation data.

You can read more details on Jetbrains profiling tools

There are plugins as well for Intellij to do profiling, check on File -> Settings -> Plugins and search for Java profiler. For instance check JProfiler.

Of course, you can use tools for benchmark calculation as Apache Commons StopWatch, which provides a convenient API for timings.

StopWatch watch = new StopWatch();
watch.start();
...
watch.stop();
System.out.println(watch.getTime());
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement