Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 972
rogerdpack Avatar asked Apr 12 '13 16:04

rogerdpack


People also ask

How do I profile in IntelliJ?

It is easy to start profiling your application – just open the Profiler tool window from the bottom toolbar, select a running process, and right-click it to choose which profiler to attach. You can then stop profiling and see the results in the same tool window.

How do I change the source release in IntelliJ?

From the main menu, select File | Project Structure Ctrl+Alt+Shift+S and click Project Settings | Modules. Select the necessary module and then open the Sources tab in the right-hand part of the dialog.


2 Answers

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

like image 78
CrazyCoder Avatar answered Oct 19 '22 15:10

CrazyCoder


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.

like image 21
smile-on Avatar answered Oct 19 '22 16:10

smile-on