How to know which part of my code takes more CPU
complexity-theory, java, recursion, time
Solution
I would like to know which lines of my code are using most of the time of execution.
Run your code using a profiler. Eclipse has profiling support, but I'd recommend using the profiler supplied as part of the JDK - VisualVM.
(I would not start by analysing the "big O" complexity. Profile first, and that will tell you where to start looking. Then you might want to formally or informally look at the algorithmic complexity of the hotspots.)
I know that there are Cyclomatic Complexity Methods.
Cyclomatic complexity is not a predictor of performance. It is (supposedly) a measure of code maintainability, not of computational complexity. The same probably goes for the "metrics2" stuff, though I'm not familiar with it.
Problem
I would like to know which lines of my code are using most of the time of execution. I am doing a planner algorithm, and to solve a specific problem I made, the computer needs 5 minutes to find the solution. I am using a lot of recursion methods, I would like to know where is the most time wasted, so I can look into that lines and try to fix or refactor the code to see if it helps. I know that there are Cyclomatic Complexity Methods. But I don't know how to use it on Eclipse. I am using Helios. Tried to install metrics2 and it just pops up errors on my Eclipse. EDITED: SMALLER NEW QUESTION: http://s7.postimg.org/frd8yjql5/diag.png What does this means? Look at the Heap Size.. Always up and down.. does this affects CPU Speed? Thanks!