repo.or.cz
/
pbc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Add Apache License version 2.0.
[pbc.git]
/
misc
/
get_time.c
blob
8932364bcf7794ef068d266c8099e06b13c42ec0
1
#include <sys/time.h>
2
#include <time.h>
3
4
double
pbc_get_time
(
void
) {
5
static struct
timeval last_tv
,
tv
;
6
static int
first
=
1
;
7
static double
res
=
0
;
8
9
if
(
first
) {
10
gettimeofday
(&
last_tv
,
NULL
);
11
first
=
0
;
12
return
0
;
13
}
else
{
14
gettimeofday
(&
tv
,
NULL
);
15
res
+=
tv
.
tv_sec
-
last_tv
.
tv_sec
;
16
res
+= (
tv
.
tv_usec
-
last_tv
.
tv_usec
) /
1000000.0
;
17
last_tv
=
tv
;
18
19
return
res
;
20
}
21
}