summaryrefslogtreecommitdiffstats
path: root/tests/clar/clar_libgit2_timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/clar/clar_libgit2_timer.c')
-rw-r--r--tests/clar/clar_libgit2_timer.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/clar/clar_libgit2_timer.c b/tests/clar/clar_libgit2_timer.c
new file mode 100644
index 0000000..6c75413
--- /dev/null
+++ b/tests/clar/clar_libgit2_timer.c
@@ -0,0 +1,30 @@
+#include "clar_libgit2.h"
+#include "clar_libgit2_timer.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)
+{
+ t->time_started = git_time_monotonic();
+}
+
+void cl_perf_timer__stop(cl_perf_timer *t)
+{
+ uint64_t time_now = git_time_monotonic();
+
+ t->last = time_now - t->time_started;
+ t->sum += t->last;
+}
+
+uint64_t cl_perf_timer__last(const cl_perf_timer *t)
+{
+ return t->last;
+}
+
+uint64_t cl_perf_timer__sum(const cl_perf_timer *t)
+{
+ return t->sum;
+}