I have got stucked where one of my function is taking some time to execute. I have a hierarchy of objects in object using object models and ArrayList(s). I just want to know the techniques by which I can debug the code to check which statement of code is taking time in execution.
Asked
Active
Viewed 1.2k times
2 Answers
15
Simply use this.
long startTime = System.nanoTime();
YourMethode();
long endTime = System.nanoTime();
long MethodeDuration = (endTime - startTime);

Remees M Syde
- 2,564
- 1
- 19
- 42
-
Didn't you understand the problem? If you already know that one method is slow you win nothing by measuring it's execution time. With your code it would be VERY exhausting to check every line of the slow code. – The incredible Jan Jul 20 '17 at 14:20
4
Two solutions :
- Display yourself the time elapsed (pretty simple and extremely powerful imho) : How do I time a method's execution in Java?
- Get more details with Traceview : http://developer.android.com/tools/debugging/systrace.html
-
Get More details [here](https://stackoverflow.com/questions/180158/how-do-i-time-a-methods-execution-in-java) – Zia Jun 15 '17 at 06:21