/* --- @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
*
* 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.
*
/* --- @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
*
* 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 -------------------------------------------------*/
/* 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);