diff options
| author | TazyFoundSoup <gardendistrict0x0@outlook.com> | 2026-05-22 21:08:04 +1000 |
|---|---|---|
| committer | TazyFoundSoup <gardendistrict0x0@outlook.com> | 2026-05-22 21:08:04 +1000 |
| commit | ee425b55c48c25c7a91b6cba315e6c2cd42d0fb7 (patch) | |
| tree | adae9e31d214db35bb8edcd267e63cdebbc438e5 | |
| parent | 373a0f0fc758b9636089a6336d8a65b1cb05571a (diff) | |
refactor(bench): move bench printing to source file
| -rw-r--r-- | include/tinyff/bench/bench.h | 14 | ||||
| -rw-r--r-- | src/bench/bench.c | 20 |
2 files changed, 21 insertions, 13 deletions
diff --git a/include/tinyff/bench/bench.h b/include/tinyff/bench/bench.h index f623e0f..f8a4ce1 100644 --- a/include/tinyff/bench/bench.h +++ b/include/tinyff/bench/bench.h @@ -61,19 +61,7 @@ static inline double ff_bench_seconds(const ff_bench *b) { return (double)(b->_end - b->_start) / CLOCKS_PER_SEC; } -static inline void ff_bench_print(ff_ctx* ctx, const ff_bench *b) -{ - double total_ms = (double)(b->_end - b->_start) * 1000.0 / CLOCKS_PER_SEC; - - ff_dprintf(ctx, "== bench: %s ==\n", b->label); - - for (int i = 0; i < b->_mcount; i++) { - double ms = (double)(b->markers[i].tick - b->_start) * 1000.0 / CLOCKS_PER_SEC; - ff_dprintf(ctx, " [%s] +%.3f ms\n", b->markers[i].label, ms); - } - - ff_dprintf(ctx, "total: %.3f ms\n", total_ms); -} +void ff_bench_print(ff_ctx* ctx, const ff_bench *b); #endif // TINYFF_BENCH_H diff --git a/src/bench/bench.c b/src/bench/bench.c new file mode 100644 index 0000000..7130619 --- /dev/null +++ b/src/bench/bench.c @@ -0,0 +1,20 @@ +#include <tinyff/bench/bench.h> +#include <tinyff/common.h> + +#ifdef USE_BENCH + +inline void ff_bench_print(ff_ctx* ctx, const ff_bench *b) +{ + double total_ms = (double)(b->_end - b->_start) * 1000.0 / CLOCKS_PER_SEC; + + ff_dprintf(ctx, "== bench: %s ==\n", b->label); + + for (int i = 0; i < b->_mcount; i++) { + double ms = (double)(b->markers[i].tick - b->_start) * 1000.0 / CLOCKS_PER_SEC; + ff_dprintf(ctx, " [%s] +%f ms\n", b->markers[i].label, ms); + } + + ff_dprintf(ctx, "total: %f ms\n", total_ms); +} + +#endif
\ No newline at end of file |
