How to test function for execution timing in android?

Aashutosh Sharma picture Aashutosh Sharma · Nov 14, 2014 · Viewed 9.9k times · Source

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.

Answer

Remees M Syde picture Remees M Syde · Nov 14, 2014

Simply use this.

long startTime = System.nanoTime();
YourMethode();
long endTime = System.nanoTime();

long MethodeDuration = (endTime - startTime);