I tried using the profiler of IntelliJ IDEA

This is T.O. of GMO Ad Marketing.

I tried using the profiler with IntelliJ IDEA Ultimate, so I will introduce the usage procedure. Easy to use: grinning:

● Premise We will use the mac version of IntelliJ IDEA Ultimate 2019.3 as the development environment. Note 1) IntelliJ profiler can be used only in the Ultimate version. Note 2) At this time, the profiler function cannot be used for application servers such as tomcat.

1. Enable profiler function

Select "Preference-> Build, Execution, Deployment-> Profilers-> Java Profiler" from the IntelliJ menu. Press the "+" button to add "CPU Profiler" and "Allocation Profiler". profiler_p1.png

A button is added to run the profiler. profiler_p2.png

2. Use profiler

2.1. CPU Profiler

Select "Run'xxxxx' with CPU Profiler" from the buttons to run the profiler. After the program has run, select the Profiler tab on the screen to display the Profiler Tools window. The collected data is displayed in three tabs: frame graph, call tree, and method list.

2.1.1. Frame graph

The frame of the called stack is displayed with a width proportional to the percentage of CPU time spent. It seems that the orange part is consumed by calling the part written in the program, and the blue part is consumed by the compile time etc. profiler_cpu_p1.png If you want to investigate where the percentage of time spent is high, you can move to the program source corresponding to the part of the frame by displaying the menu with the frame selected and selecting "Jump To Source". profiler_cpu_p1-2.png

2.1.2. Call tree

Information about the program's call stack (method name, percentage of total CPU time spent, etc.) is displayed. The arrow on the far left is a hierarchical display, and you can check it in more detail by selecting it. profiler_cpu_p2.png

2.1.3. Method list

The executed methods are displayed in descending order of cumulative CPU time consumption. If you select "Back Traces" at the bottom with each method selected, you can check the method that is calling. profiler_cpu_p3.png

2.2. Allocation Profiler

Select "Run'xxxxx' with Allocation Profiler" from the buttons to run the profiler. After the program has run, select the Profiler tab on the screen to display the Profiler Tools window. The collected data is displayed in three tabs: frame graph, call tree, and method list.

2.2.1. Frame graph

The frame of the called stack is displayed with a width proportional to the percentage of memory consumption. If you want to investigate where the memory consumption is high, you can move to the program source corresponding to the part of the frame by displaying the menu with the frame selected and selecting "Jump To Source" from the menu. profiler_allocation_p1.png

2.2.2. Call tree

Information about the program's call stack (method name, percentage of total memory consumption, etc.) is displayed. profiler_allocation_p2.png The arrow on the far left is a hierarchical display, and you can check it in more detail by selecting it. profiler_allocation_p3.png

2.2.3. Method list

The executed methods are displayed in descending order of cumulative memory amount. If you select "Back Traces" at the bottom with each method selected, you can check the method that is calling. profiler_allocation_p4.png

reference

In writing, I referred to the following. [Profiling Tool-Official Help | IntelliJ IDEA] (https://pleiades.io/help/idea/cpu-profiler.html)

Tomorrow is "How to deal with missing values by machine learning" by @CodeDiggerM. Please continue to enjoy GMO Advent Calendar 2019!

Recommended Posts

I tried using the profiler of IntelliJ IDEA
I tried the new feature profiler of IntelliJ IDEA 2019.2.
I tried using the Server Push function of Servlet 4.0
I tried using GoogleHttpClient of Java
The secret to the success of IntelliJ IDEA
I tried using the cache function of Application Container Cloud Service
I tried using Docker for the first time
I tried using Gson
I tried using TestNG
I tried using Galasa
[API] I tried using the zip code search API
The idea of quicksort
The idea of jQuery
I tried to summarize the state transition of docker
05. I tried to stub the source of Spring Boot
I tried to reduce the capacity of Spring Boot
I tried using the Migration Toolkit for Application Binaries
I tried installing the Docker Integration plugin in IntelliJ
[WIP] I tried the configuration of Docker + Streama + NFS
I tried using azure cloud-init
I tried using Apache Wicket
I tried the VueJS tutorial!
Try using IntelliJ IDEA once
I tried using Java REPL
I tried the FizzBuzz problem
A memorandum because I was addicted to the setting of the Android project of IntelliJ IDEA
I tried using the GitHub repository as a library server
[Rails] I tried using the button_to method for the first time
I tried to summarize the basics of kotlin and java
[Swift] I tried to implement the function of the vending machine
I tried JAX-RS and made a note of the procedure
I tried to summarize the basic grammar of Ruby briefly
I tried to build the environment little by little using docker
I tried to build the environment of WSL2 + Docker + VSCode
I tried using the CameraX library with Android Java Fragment
I tried to make the sample application into a microservice according to the idea of the book "Microservice Architecture".
I tried to touch the asset management application using the emulator of the distributed ledger Scalar DLT
I tried using anakia + Jing now
I tried using JOOQ with Gradle
I read the source of ArrayList I read
I read the source of Integer
I read the source of Long
I tried the Java framework "Quarkus"
[Rails] I tried deleting the application
I tried using Java8 Stream API
I read the source of Byte
I tried using WebAssembly Stadio (2018/4/17 version)
I read the source of String
I tried using Java memo LocalDate
I tried to solve the problem of "multi-stage selection" with Ruby
[Metal] I tried to figure out the flow until rendering using Metal
I tried to build the environment of PlantUML Server with Docker
I tried the input / output type of Java Lambda ~ Map edition ~
I tried to check the operation of gRPC server with grpcurl
I tried to summarize the methods of Java String and StringBuilder
I tried to display the calendar on the Eclipse console using Java.
I tried to solve the problem of Google Tech Dev Guide
I tried using Elasticsearch API in Java
Try using || instead of the ternary operator
I tried to summarize the methods used
I tried using Realm with Swift UI