]>
Commit | Line | Data |
---|---|---|
9a859ef5 JH |
1 | #include "clar_libgit2.h" |
2 | #include "clar_libgit2_timer.h" | |
9a859ef5 JH |
3 | |
4 | void cl_perf_timer__init(cl_perf_timer *t) | |
5 | { | |
6 | memset(t, 0, sizeof(cl_perf_timer)); | |
7 | } | |
8 | ||
9a859ef5 JH |
9 | void cl_perf_timer__start(cl_perf_timer *t) |
10 | { | |
e5cf1c70 | 11 | t->time_started = git__timer(); |
9a859ef5 JH |
12 | } |
13 | ||
14 | void cl_perf_timer__stop(cl_perf_timer *t) | |
15 | { | |
e5cf1c70 | 16 | double time_now = git__timer(); |
9a859ef5 | 17 | |
e5cf1c70 JH |
18 | t->last = time_now - t->time_started; |
19 | t->sum += t->last; | |
9a859ef5 JH |
20 | } |
21 | ||
22 | double cl_perf_timer__last(const cl_perf_timer *t) | |
23 | { | |
e5cf1c70 | 24 | return t->last; |
9a859ef5 JH |
25 | } |
26 | ||
27 | double cl_perf_timer__sum(const cl_perf_timer *t) | |
28 | { | |
e5cf1c70 | 29 | return t->sum; |
9a859ef5 | 30 | } |