File: monoclock.h

package info (click to toggle)
python-scrypt 0.9.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 832 kB
  • sloc: ansic: 6,290; python: 733; sh: 99; makefile: 5
file content (36 lines) | stat: -rw-r--r-- 1,111 bytes parent folder | download | duplicates (4)
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
#ifndef MONOCLOCK_H_
#define MONOCLOCK_H_

#include <sys/time.h>

/* Macro to simplify benchmarks. */
#define timeval_diff(x, y) ((double)((y).tv_sec - (x).tv_sec) +		\
    (double)((y).tv_usec - (x).tv_usec) * 0.000001)

/**
 * monoclock_get(tv):
 * Store the current time in ${tv}.  If CLOCK_MONOTONIC is available, use
 * that clock; if CLOCK_MONOTONIC is unavailable, use CLOCK_REALTIME (if
 * available) or gettimeofday(2).
 */
int monoclock_get(struct timeval *);

/**
 * monoclock_get_cputime(tv):
 * Store in ${tv} the duration the process has been running if
 * CLOCK_PROCESS_CPUTIME_ID is available; fall back to monoclock_get()
 * otherwise.
 */
int monoclock_get_cputime(struct timeval *);

/**
 * monoclock_getres(resd):
 * Store an upper limit on timer granularity in ${resd}.  If CLOCK_MONOTONIC
 * is available, use that clock; if CLOCK_MONOTONIC is unavailable, use
 * CLOCK_REALTIME (if available) or gettimeofday(2).  For this value to be
 * meaningful, we assume that clock_getres(x) succeeds iff clock_gettime(x)
 * succeeds.
 */
int monoclock_getres(double *);

#endif /* !MONOCLOCK_H_ */