summaryrefslogtreecommitdiff
path: root/tests/diff/diff_helpers.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-04-29 11:29:49 -0700
committerRussell Belfer <rb@github.com>2014-05-02 09:21:33 -0700
commitb23b112dfe8eceb39eaaea2d5e60d971c4371aa0 (patch)
tree56a6c981856e5f1bf830c3b647a8a58838b044f5 /tests/diff/diff_helpers.c
parent225aab5d6a611076b22f00ae5a28184d92b5259c (diff)
downloadlibgit2-b23b112dfe8eceb39eaaea2d5e60d971c4371aa0.tar.gz
Add payloads, bitmaps to trace API
This is a proposed adjustment to the trace APIs. This makes the trace levels into a bitmask so that they can be selectively enabled and adds a callback-level payload, plus a message-level payload. This makes it easier for me to a GIT_TRACE_PERF callbacks that are simply bypassed if the PERF level is not set.
Diffstat (limited to 'tests/diff/diff_helpers.c')
-rw-r--r--tests/diff/diff_helpers.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/diff/diff_helpers.c b/tests/diff/diff_helpers.c
index 279cb20c5..5de9834ba 100644
--- a/tests/diff/diff_helpers.c
+++ b/tests/diff/diff_helpers.c
@@ -229,3 +229,22 @@ void diff_print_raw(FILE *fp, git_diff *diff)
git_diff_print(diff, GIT_DIFF_FORMAT_RAW,
git_diff_print_callback__to_file_handle, fp ? fp : stderr));
}
+
+void diff_perf_track_stats(
+ git_trace_level_t level,
+ void *cb_payload,
+ void *msg_payload,
+ const char *msg)
+{
+ diff_perf *data = cb_payload;
+
+ if (!(level & GIT_TRACE_PERF))
+ return;
+
+ if (!strcmp("stat", msg))
+ data->stat_calls += msg_payload ? *((size_t *)msg_payload) : 1;
+ else if (!strcmp("submodule_lookup", msg))
+ data->submodule_lookups++;
+ else if (!strcmp("oid_calculation", msg))
+ data->oid_calcs++;
+}