I am trying to find the time taken by each method that my Java program calls, while executing. I do not want to litter my code with System.currentTimeMillis()
. Maybe, something like a profiler or an IDE plugin, but I am not sure if that is what it is called. Can someone help me by pointing me in the right direction?
Sample code :
public static void main(String[] args){
Obj A = new Obj();
ObjDiff B = new ObjDiff();
A.callMe();
B.callMeToo();
}
Tools/Frameworks :
- Eclipse
- Struts
What I Want :
- Time taken to instantiate
Obj A
, - Time taken to instantiate
ObjDiff B
, - Time taken to run
A.callMe()
, - Time taken to run
B.callMeToo()
Any help will be greatly appreciated.
Cheers,
Rohitesh
EDIT :
I have installed VisualVM and used it as a standalone app. It has been helpful. However, my primary concern is still not addressed. I cannot look at the memory/CPU usage, method wise. Any thoughts on this?