summaryrefslogtreecommitdiff
path: root/src/c/jerasure/include/timing.h
blob: b489d0d1e5e8ea01112c218f2b3ae1b7221ca6fb (plain)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Timing measurement utilities.

#ifndef JERASURE_INCLUDED__TIMING_H
#define JERASURE_INCLUDED__TIMING_H

// Define USE_CLOCK to use clock(). Otherwise use gettimeofday().
#define USE_CLOCK

#ifdef USE_CLOCK
#include <time.h>
#else
#include <sys/time.h>
#endif

struct timing {
#ifdef USE_CLOCK
  clock_t clock;
#else
  struct timeval tv;
#endif
};

// Get the current time as a double in seconds.
double
timing_now(
  void);

// Set *t to the current time.
void
timing_set(
  struct timing * t);

// Get *t as a double in seconds.
double
timing_get(
  struct timing * t);

// Return *t2 - *t1 as a double in seconds.
double
timing_delta(
  struct timing * t1,
  struct timing * t2);
#endif