first and last commit
This commit is contained in:
commit
c9e78fd810
381 changed files with 37141 additions and 0 deletions
37
timing.h
Normal file
37
timing.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
ulong tmr_time() {
|
||||
struct timespec tm;
|
||||
if(clock_gettime((clockid_t)sys.tmr_timer, &tm)) {
|
||||
return 0ULL;
|
||||
}
|
||||
return tm.tv_sec * 1000000ULL + tm.tv_nsec / 1000ULL;
|
||||
}
|
||||
|
||||
ulong tmr_ntime() {
|
||||
struct timespec tm;
|
||||
if(clock_gettime((clockid_t)sys.tmr_timer, &tm)) {
|
||||
return 0ULL;
|
||||
}
|
||||
return tm.tv_sec * 1000000000ULL + tm.tv_nsec;
|
||||
}
|
||||
|
||||
ulong tmr_rtime() {
|
||||
return tmr_time() - sys.tmr_start;
|
||||
}
|
||||
|
||||
double tmr_ftime() {
|
||||
return ((double)tmr_rtime()) / 1000000.0;
|
||||
}
|
||||
|
||||
clockid_t tmr_gettimer() {
|
||||
struct timespec tm;
|
||||
clockid_t timer = CLOCK_MONOTONIC_RAW;
|
||||
if(clock_gettime(timer, &tm)) {
|
||||
timer = CLOCK_MONOTONIC;
|
||||
if(clock_gettime(timer, &tm)) {
|
||||
timer = CLOCK_REALTIME;
|
||||
sys_assert(!clock_gettime(timer, &tm))
|
||||
}
|
||||
}
|
||||
return timer;
|
||||
}
|
Reference in a new issue