I would like to measure time in C, and I am having a tough time figuring it out, all I want is something like this:
- start a timer
- run a method
- stop the timer
- report the time taken (at least to micro accuracy)
Any help would be appreciated.
(I am compiling in windows using mingw)
Using the time.h library, try something like this:
If your Linux system supports it, clock_gettime(CLOCK_MONOTONIC) should be a high resolution timer that is unaffected by system date changes (e.g. NTP daemons).