forked from bitcoin-core/secp256k1
-
Notifications
You must be signed in to change notification settings - Fork 13
/
timer.h
25 lines (16 loc) · 816 Bytes
/
timer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright (c) 2016 Llamasoft
#ifndef __TIMER_H__
#define __TIMER_H__
#include <time.h>
#define UNIT_MAGNITUDE (1000)
#define TO_SECOND (1)
#define TO_MILLISECOND (UNIT_MAGNITUDE * TO_SECOND)
#define TO_MICROSECOND (UNIT_MAGNITUDE * TO_MILLISECOND)
#define TO_NANOSECOND (UNIT_MAGNITUDE * TO_MICROSECOND)
// WARNING: THESE ARE CLOCK FUNCTIONS, NOT TIME FUNCTIONS
// Do not expect a time-of-day representation from any of the below functions
struct timespec get_clock();
long get_clockdiff_ns(struct timespec prev_clock); // Returns clock difference in nanoseconds
long get_clockdiff_ms(struct timespec prev_clock); // Returns clock difference in milliseconds
double get_clockdiff_s(struct timespec prev_clock); // Returns clock difference in seconds
#endif