What is best method to measure execution time of Android code snippet?
I have a section of code before and after which I want to place timestamps to find out it\'s e
What would be the best way to measure execution time
System.nanoTime() is probably a good choice. Jake Wharton is using that with Hugo, for example.
and get good precision
This is not strictly possible, as anything can happen on the device while your method is executing. Those external factors will affect your time measurements, by stealing away CPU time, tying up I/O channels, etc. You need to average your tests across several runs to try to average out those external factors, and accuracy/precision will suffer as a result.
And, as Marcin Orlowski notes, to actually figure out why you are consuming certain amounts of time, use Traceview.