From 8d372122ebab7e141ec3dd357c7673f7413f19ea Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Mon, 11 Mar 2024 13:04:04 +0000 Subject: [PATCH] @@@ bench man --- test/bench.c | 11 ++++++----- test/bench.h | 8 ++++---- test/tvec-bench.c | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/test/bench.c b/test/bench.c index 225d40c..7fedc9d 100644 --- a/test/bench.c +++ b/test/bench.c @@ -724,8 +724,8 @@ end: /* --- @bench_measure@ --- * * - * Arguments: @struct bench_timing *t_out@ = where to leave the timing - * @struct bench_state *b@ = benchmark state + * Arguments: @struct bench_state *b@ = benchmark state + * @struct bench_timing *t_out@ = where to leave the timing * @double base@ = number of internal units per call * @bench_fn *fn@, @void *ctx@ = benchmark function to run * @@ -741,15 +741,16 @@ end: * performs, or the number of bytes it processes per iteration). */ -int bench_measure(struct bench_timing *t_out, struct bench_state *b, +int bench_measure(struct bench_state *b, struct bench_timing *t_out, double base, bench_fn *fn, void *ctx) { struct bench_timer *tm = b->tm; struct bench_time t0, t1; unsigned long n, nn; - /* Make sure the state is calibrated. */ - if (bench_calibrate(b)) return (-1); + /* Make sure the state is calibrated and usable. */ + if (!(b->f&BTF_CLB) && bench_calibrate(b)) return (-1); + if (!(b->f&BTF_TIMEOK)) return (-1); /* Main adaptive measurement loop. * diff --git a/test/bench.h b/test/bench.h index bca3b01..0645068 100644 --- a/test/bench.h +++ b/test/bench.h @@ -148,8 +148,8 @@ extern int bench_calibrate(struct bench_state */*b*/); /* --- @bench_measure@ --- * * - * Arguments: @struct bench_timing *t_out@ = where to leave the timing - * @struct bench_state *b@ = benchmark state + * Arguments: @struct bench_state *b@ = benchmark state + * @struct bench_timing *t_out@ = where to leave the timing * @double base@ = number of internal units per call * @bench_fn *fn@, @void *ctx@ = benchmark function to run * @@ -165,8 +165,8 @@ extern int bench_calibrate(struct bench_state */*b*/); * performs, or the number of bytes it processes per iteration). */ -extern int bench_measure(struct bench_timing */*t_out*/, - struct bench_state */*b*/, +extern int bench_measure(struct bench_state */*b*/, + struct bench_timing */*t_out*/, double /*base*/, bench_fn */*fn*/, void */*ctx*/); /*----- That's all, folks -------------------------------------------------*/ diff --git a/test/tvec-bench.c b/test/tvec-bench.c index c81fd68..dda5713 100644 --- a/test/tvec-bench.c +++ b/test/tvec-bench.c @@ -388,7 +388,7 @@ void tvec_benchrun(struct tvec_state *tv, tvec_testfn *fn, void *ctx) /* Run the benchmark. */ o->ops->bbench(o, d.buf, unit); - if (bench_measure(&tm, bc->bst, base, loopfn, &r)) + if (bench_measure(bc->bst, &tm, base, loopfn, &r)) o->ops->ebench(o, d.buf, unit, 0); else o->ops->ebench(o, d.buf, unit, &tm); -- 2.11.0