summaryrefslogtreecommitdiff
path: root/src/timing.h
blob: 6ee631a01b1c1421efd9a89647b345f1c976bcec (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
44
45
46
47
48
/*
 * Copyright (C) the libgit2 contributors. All rights reserved.
 *
 * This file is part of libgit2, distributed under the GNU GPL v2 with
 * a Linking Exception. For full terms see the included COPYING file.
 */
#ifndef INCLUDE_timing_h__
#define INCLUDE_timing_h__

#include "common.h"

#ifndef GIT_WIN32
# include <time.h>
#endif

#ifdef __APPLE__
# include <mach/mach_time.h>
#endif

#ifdef GIT_WIN32

typedef struct git_stopwatch {
	LARGE_INTEGER freq;
	LARGE_INTEGER start;
	unsigned running : 1;
} git_stopwatch;

#elif __APPLE__

typedef struct git_stopwatch {
	mach_timebase_info_data_t info;
	uint64_t start;
	unsigned running : 1;
} git_stopwatch;

#else

typedef struct git_stopwatch {
	struct timespec start;
	unsigned running : 1;
} git_stopwatch;

#endif

extern int git_stopwatch_start(git_stopwatch *s);
extern int git_stopwatch_query(double *out_elapsed_seconds, git_stopwatch *s);

#endif