]> git.proxmox.com Git - libgit2.git/blob - tests/clar_libgit2_timer.c
install as examples
[libgit2.git] / tests / clar_libgit2_timer.c
1 #include "clar_libgit2.h"
2 #include "clar_libgit2_timer.h"
3 #include "buffer.h"
4
5 void cl_perf_timer__init(cl_perf_timer *t)
6 {
7 memset(t, 0, sizeof(cl_perf_timer));
8 }
9
10 void cl_perf_timer__start(cl_perf_timer *t)
11 {
12 t->time_started = git__timer();
13 }
14
15 void cl_perf_timer__stop(cl_perf_timer *t)
16 {
17 double time_now = git__timer();
18
19 t->last = time_now - t->time_started;
20 t->sum += t->last;
21 }
22
23 double cl_perf_timer__last(const cl_perf_timer *t)
24 {
25 return t->last;
26 }
27
28 double cl_perf_timer__sum(const cl_perf_timer *t)
29 {
30 return t->sum;
31 }