diff options
| author | Shinya Sato <shinnya.sato@gmail.com> | 2021-09-24 16:42:54 +0900 |
|---|---|---|
| committer | Shinya Sato <shinnya.sato@gmail.com> | 2021-09-24 16:42:54 +0900 |
| commit | 6b3075d90d945d5e7e8fd4d28284ffd99dbeb82e (patch) | |
| tree | 4d9e58166e36452bc3a19172d9cfb7a245f996b0 /src/timer.h | |
| parent | dd62122ee43d2c388fb96518eaa527976fddfc38 (diff) | |
| download | inpla-6b3075d90d945d5e7e8fd4d28284ffd99dbeb82e.tar.gz inpla-6b3075d90d945d5e7e8fd4d28284ffd99dbeb82e.zip | |
v0.4.1
Diffstat (limited to 'src/timer.h')
| -rw-r--r-- | src/timer.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/timer.h b/src/timer.h new file mode 100644 index 0000000..904bd6a --- /dev/null +++ b/src/timer.h @@ -0,0 +1,31 @@ +//https://github.com/zuqqhi2/numerical_simulation/blob/master/multithread/laytrace/timer.h + +#ifndef _H_TIMER +#define _H_TIMER + +#include <stdio.h> +#include <sys/time.h> + +static inline +unsigned long long gettimeval(void) { + struct timeval tv; + struct timezone tz; + gettimeofday(&tv, &tz); + return ((unsigned long long)tv.tv_sec)*1000000+tv.tv_usec; +} + +static inline +void start_timer(unsigned long long *startt) { + *startt = gettimeval(); + return; +} + +static inline +unsigned long long stop_timer(unsigned long long *startt) { + unsigned long long stopt = gettimeval(); + return (stopt>=*startt)?(stopt-*startt):(stopt); +} + +#define print_timer(te) {printf("time of %s:%f[sec]\n", #te, (te*1.0e-3)/1000);} + +#endif |
