Created
October 26, 2021 10:42
-
-
Save Jerrylum/19654ad218f82a02075e71a796e09767 to your computer and use it in GitHub Desktop.
Lazy time test macro
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
#define TIMETEST(name, content) struct timeval tval_before_##name, tval_after_##name, tval_result_##name; \ | |
gettimeofday(&tval_before_##name, NULL); \ | |
content \ | |
gettimeofday(&tval_after_##name, NULL); \ | |
timersub(&tval_after_##name, &tval_before_##name, &tval_result_##name); \ | |
printf(#name " %ld.%06ld\n", (long int)tval_result_##name.tv_sec, (long int)tval_result_##name.tv_usec); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment