Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quickiest/easiest way to find methods in Java/Android that take a second or more to execute

I am trying to figure out which methods (esp on the Main Thread) take more than a second to execute. Unfortunately I am using DDMS and traceview, but i don't really understand how to read the data provided. Is there an easy way to find long running methods?

like image 851
StackOverflowed Avatar asked Oct 31 '13 03:10

StackOverflowed


2 Answers

@Jake Wharton just released Hugo which would allow you to annotate methods and receive the running time of those methods in logcat.

like image 197
Justin Muller Avatar answered Sep 30 '22 17:09

Justin Muller


You can simply print the time each time you call a method along with the method name. Then you just look to see when the difference between the previous time stamp is longer than however long you would like (1 second)

Calendar c = Calendar.getInstance(); 
int seconds = c.get(Calendar.SECOND);
like image 26
ghostbust555 Avatar answered Sep 30 '22 18:09

ghostbust555