Created
April 11, 2013 15:18
-
-
Save almorel/5364231 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdint.h> | |
#include <time.h> | |
int64_t timespecDiff(struct timespec *timeA_p, struct timespec *timeB_p) | |
{ | |
return ((timeA_p->tv_sec * 1000000000) + timeA_p->tv_nsec) - | |
((timeB_p->tv_sec * 1000000000) + timeB_p->tv_nsec); | |
} | |
int main(int argc, char **argv) | |
{ | |
struct timespec start, end; | |
clock_gettime(CLOCK_MONOTONIC, &start); | |
// Some code I am interested in measuring | |
clock_gettime(CLOCK_MONOTONIC, &end); | |
uint64_t timeElapsed = timespecDiff(&end, &start); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment