]> git.proxmox.com Git - libgit2.git/blame - tests/clar_libgit2_timer.c
New upstream version 1.4.3+dfsg.1
[libgit2.git] / tests / clar_libgit2_timer.c
CommitLineData
9a859ef5
JH
1#include "clar_libgit2.h"
2#include "clar_libgit2_timer.h"
9a859ef5
JH
3
4void cl_perf_timer__init(cl_perf_timer *t)
5{
6 memset(t, 0, sizeof(cl_perf_timer));
7}
8
9a859ef5
JH
9void cl_perf_timer__start(cl_perf_timer *t)
10{
e5cf1c70 11 t->time_started = git__timer();
9a859ef5
JH
12}
13
14void 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
22double cl_perf_timer__last(const cl_perf_timer *t)
23{
e5cf1c70 24 return t->last;
9a859ef5
JH
25}
26
27double cl_perf_timer__sum(const cl_perf_timer *t)
28{
e5cf1c70 29 return t->sum;
9a859ef5 30}