Created
October 29, 2013 16:52
-
-
Save cramsay/7218427 to your computer and use it in GitHub Desktop.
Smeed: C time macros - second based.
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 <time.h> | |
| /* The following timing-related macros are based on the reaction.c | |
| * versions except that they are time_t and time() specific rather | |
| * than clock_t and clock() specific since the latter aren't | |
| * suitable for timing I/O bound programs. | |
| */ | |
| static time_t _startTime,_stopTime; /* 'private' variables */ | |
| #define SNAP() (_startTime = time(NULL)) | |
| #define SHOT() (_stopTime = time(NULL)) | |
| #define ELAPSED() (difftime(_stopTime,_startTime)) | |
| #define RUNTIME() (difftime(time(NULL),_startTime)) | |
| /* PAUSE(): a crude delay system - it waits for d seconds to expire. */ | |
| #define PAUSE(d) {SNAP();while ((int)RUNTIME() < d);} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment