-
Notifications
You must be signed in to change notification settings - Fork 0
/
bftime.c
76 lines (59 loc) · 1.51 KB
/
bftime.c
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*------------------------------------------------------------------------*/
/* Copyright (c) 2005 - 2010 Armin Biere, Johannes Kepler University. */
/*------------------------------------------------------------------------*/
#include "config.h"
#ifdef __MINGW32__
#include <windows.h>
#else
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/unistd.h>
#endif
#include <stdarg.h>
#include "bftime.h"
/*------------------------------------------------------------------------*/
double
booleforce_time_stamp (void)
{
double res;
res = 0;
# ifdef __MINGW32__
{
FILETIME tmp[2], u, s;
__int64 s64, u64;
if (GetProcessTimes (GetCurrentProcess (), tmp, tmp + 1, &s, &u))
{
s64 = s.dwLowDateTime;
s64 |= (__int64) s.dwHighDateTime << 32;
u64 = u.dwLowDateTime;
u64 |= (__int64) u.dwHighDateTime << 32;
res = (s64 + u64) / 1e7;
}
}
# else
{
struct rusage u;
if (!getrusage (RUSAGE_SELF, &u))
{
res += u.ru_utime.tv_sec + 1e-6 * u.ru_utime.tv_usec;
res += u.ru_stime.tv_sec + 1e-6 * u.ru_stime.tv_usec;
}
}
# endif
return res;
}
/*------------------------------------------------------------------------*/
void
booleforce_report (double start_time, FILE * file, const char *fmt, ...)
{
double now, passed;
va_list ap;
va_start (ap, fmt);
vfprintf (file, fmt, ap);
va_end (ap);
now = booleforce_time_stamp ();
passed = now - start_time;
passed = (passed < 0) ? 0 : passed;
fprintf (file, " in %.2f seconds\n", passed);
fflush (file);
}