diff options
| author | TazyFoundSoup <gardendistrict0x0@outlook.com> | 2026-05-05 19:59:44 +1000 |
|---|---|---|
| committer | TazyFoundSoup <gardendistrict0x0@outlook.com> | 2026-05-05 19:59:44 +1000 |
| commit | c181cad8fb6d779d2ca01e6870501e82384f8e82 (patch) | |
| tree | b9b3eda3b4d6877346f2d2cc80fa11625fe1df0f | |
| parent | 301505e08ef2bc091b38b55aaae8bc6b66cea83b (diff) | |
feat(bench): add benchmarking macros and instrumentation hooks
| -rw-r--r-- | include/tinyff/common.h | 28 |
1 files changed, 26 insertions, 2 deletions
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 <tinyff/bench.h> +#include <bench.h> + +#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; |
