Search code examples
javaprofiler

How do I analyze which method consumed more time in java,eclipse,junit?


This may be a silly question for some pro java coders but I am going mad right now, so I am still asking. Please guide me in right direction someone.

How do I analyze which method/partOfMethod is consuming more time in my java program?

(I am using Eclipse and Junit)


Solution

  • Use jvisualvm. It is bundled in with the JDK nowadays, but a standalone version exists as well, which is more up to date. Typically, when you start it you can pick which running java process to connect to (this may well be our running unit test). You can specify which qualified class name filters you need to track. Normally, some class instrumentation will ensue, and you will be able to track the processing time allocated to each method (cumulative time as well).