0

I need to read timestamps using C or Assembly code on Android NDK, but it is important to do that with very low overhead. I'm trying to do some code instrumentation that will add code snippets at beggining of every function in Android native code to measure functions execution times (kind of profiler).

Is it any more efficient way than gettimeofday() ? I already tried reading Time Stamp Counter to convert results to clock time but it doesn't work for me ex.1 ex.2

Community
  • 1
  • 1
Wojciech Marusarz
  • 342
  • 1
  • 2
  • 10
  • You do realize that measuring clock time on a multitasking system does not necessarily indicate how much time has been spent executing code from the thread under study. – Chris Stratton Mar 05 '15 at 19:03
  • There's a [*better way to do it*](http://stackoverflow.com/a/378024/23771), not by trying to measure elapsed time of functions, but by taking stack samples at random times. The fraction of samples containing the function estimates the inclusive fraction of time it takes. If its time fraction is 10%, for example, it will show up approximately once in every 10 samples. You don't have to care if time is spent in other threads because that doesn't change the percents very much. – Mike Dunlavey Mar 06 '15 at 13:23

0 Answers0