Last active
December 21, 2015 23:49
-
-
Save ursachec/6385082 to your computer and use it in GitHub Desktop.
Macros for measuring running times in C.
This file contains 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
#ifndef __mrt_timer_h__ | |
#define __mrt_timer_h__ | |
#include <sys/time.h> | |
#define mrt_timer_setup() \ | |
struct timeval mrt_te; \ | |
time_t mrt_start = 0, mrt_end = 0; | |
#define mrt_timer_start() \ | |
gettimeofday(&mrt_te, NULL); \ | |
mrt_start = ((time_t)mrt_te.tv_sec * 1000LL + (time_t)mrt_te.tv_usec / 1000LL); | |
#define mrt_timer_stop() \ | |
gettimeofday(&mrt_te, NULL); \ | |
mrt_end = ((time_t)mrt_te.tv_sec * 1000LL + (time_t)mrt_te.tv_usec / 1000LL) - mrt_start; | |
#define mrt_timer_get_elapsed() mrt_end | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment