how do you profile java source with intellij idea editor? [closed]
Asked Answered
A

2

83

I know that Netbeans has something of an "integrated" profiler, for instance you can run unit tests and use it to analyze and find what is slowing them down, where bottlenecks are. Is it possible to profile code within IntelliJ IDEA editor?

Anabelanabella answered 12/4, 2013 at 16:43 Comment(6)
As far as I know there is only one free profiler integration: VisualVM.Duiker
Apparently there's a non-free JProfiler plugin, FWIW https://mcmap.net/q/244283/-is-there-an-intellij-java-profiler-closedAnabelanabella
Today I have installed the plugin VisualVM in INtellij IDEA ... initially I faced some issue but when I followed instructions provided in blog.idrsolutions.com/2013/05/… I could easily configure visualVMCaddie
Another question that's far too practical and useful to remain open. SO should support questions with answer sets {N} where good enough result(s) from set: [X, Y, Z] rise to the top via the community and the rest disappear/require extra action due to a natural falloff. Again via the community. "Do you really want to answer this? Cause there's already an answer voted pretty dang good?" "Yea, cause now there's a better best answer." I mean that never happens in software right?Ararat
FYI: In IntelliJ IDEA v2018.3 Ultimate edition, the JVM Profiler is available as an experimental feature. See blog.jetbrains.com/idea/2018/09/…Malm
For Windows profiler, use 2019.2 RC: blog.jetbrains.com/idea/2019/06/…Florella
D
56

You can try the free VisualVM profiler integration via a plug-in.

Duiker answered 18/4, 2013 at 20:26 Comment(7)
Looks like if you buy IntelliJ "ultimate" it's said to include a built-in YourKit profiling agent, as well. Not free, but included, so I guess related to my original question :)Anabelanabella
No, YourKit agent will allow you to take CPU/Memory snapshot when contacting support with performance problems, it's not the profiler itself which will cost you additional $500+.Duiker
appears you're right thanks for the clarification. YourKit is apparently only for profiling the IDE itself, not your own apps. Guess I'll just turn to Netbeans for now when I need to profile, and do the rest of my programming in IntelliJ :)Anabelanabella
@Anabelanabella why not just open VisualVM (you already have it installed through the jdk), select your app and press profile?Stripling
The problem with VisualVM launced by Krasa's VisualVM Launcher plugin: 1) at the time it starts your test has finished. 2) on-fly profiling creates hot spots and hard to read CPU time stats. There is a checkbox "edit configuration" in VisualVM but I don't see how to ask plugin to start test in right way - wait until VisualVM starts and ready - load test specific profiling config into VisualVM - run test codeEthic
YourKit version 2013 is not free but definetly claims functionality of stand alone java profiler with IDE Integration, IntelliJ IDEA 13 supported. Look at YourKit version 2013 release note.Ethic
@Ethic Did you find a solution to the problem where your tests finish before VisualVM has launched? I am having the same problem myself.Murrhine
E
27

As pointed by Stephen Murby "the problem where your tests finish before VisualVM has launched".

Yes, this VisualVMLauncher plug-in does not put your test case on hold until VisualVM has started. You may also need time to manually change profiling settings specific for the test. Solution is simple, your test case has to stop and wait until you manually tells it to continue. There are few ways of doing it:

1) put System.in.read(); as first line of test case and as VisualVM is ready press enter at console.

System.in.read();

2) If test case runner does not provide you with console, put wait until some magic file is created.

3) you can always play easy with sleep()

sleep(5 seconds);

This work around is not much of convenience but works for me as need to profile occasionally. The root cause of issue is in plug-in architecture of both IDEA and VisualVM are not thought to be collaborative. See discussion with plug-in author Hope that helps.

Ethic answered 28/3, 2014 at 14:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.