From c181cad8fb6d779d2ca01e6870501e82384f8e82 Mon Sep 17 00:00:00 2001 From: TazyFoundSoup Date: Tue, 5 May 2026 19:59:44 +1000 Subject: feat(bench): add benchmarking macros and instrumentation hooks --- include/tinyff/common.h | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/tinyff/common.h b/include/tinyff/common.h index 370fc8e..34209e8 100644 --- a/include/tinyff/common.h +++ b/include/tinyff/common.h @@ -10,7 +10,31 @@ #ifdef USE_BENCH -#include +#include + +#define FF_BENCH_MARK(ctx, label) \ + do { \ + if (ctx) \ + ff_bench_mark(&(ctx)->bench, (label)); \ + } while (0) + +#define FF_BENCH_START(ctx, label) \ + do { \ + if (ctx) \ + ff_bench_start(&(ctx)->bench, (label)); \ + } while (0) + +#define FF_BENCH_END(ctx) \ + do { \ + if (ctx) \ + ff_bench_end(&(ctx)->bench); \ + } while (0) + +#else + +#define FF_BENCH_MARK(ctx, label) do {} while (0) +#define FF_BENCH_START(ctx, label) do {} while (0) +#define FF_BENCH_END(ctx) do {} while (0) #endif @@ -76,7 +100,7 @@ typedef struct { void* (*ff_calloc)(size_t count, size_t size); } ff_allocator; -typedef struct { +typedef struct ff_ctx { // Debug settings ff_stream ff_debug_stream; ff_flag ff_debug_enabled; -- cgit v1.2.3