user41926: I tried using millis, but I wanted to know if there is any better way to find out the exact time from when a function is called and finally when it terminates.

user359: There is micros() which returns the number of microseconds the board has been active. But it rolls over much more frequently (a bit over an hour vs the month and a half for millis())
unsigned long preFunction = micros();
foo();
unsigned long timeElapsed = micros() - preFunction;


41926: <p>I tried using millis, but I wanted to know if there is any better way to find out the exact time from when a function is called and finally when it terminates.</p>
 359: <p>There is <code>micros()</code> which returns the number of microseconds the board has been active. But it rolls over much more frequently (a bit over an hour vs the month and a half for <code>millis()</code>)</p>

<pre><code>unsigned long preFunction = micros();
foo();
unsigned long timeElapsed = micros() - preFunction;
</code></pre>
