clar_libgit2_timer.c 531 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11
#include "clar_libgit2.h"
#include "clar_libgit2_timer.h"
#include "buffer.h"

void cl_perf_timer__init(cl_perf_timer *t)
{
	memset(t, 0, sizeof(cl_perf_timer));
}

void cl_perf_timer__start(cl_perf_timer *t)
{
12
	t->time_started = git__timer();
13 14 15 16
}

void cl_perf_timer__stop(cl_perf_timer *t)
{
17
	double time_now = git__timer();
18

19 20
	t->last = time_now - t->time_started;
	t->sum += t->last;
21 22 23 24
}

double cl_perf_timer__last(const cl_perf_timer *t)
{
25
	return t->last;
26 27 28 29
}

double cl_perf_timer__sum(const cl_perf_timer *t)
{
30
	return t->sum;
31
}