@@@ bench man
authorMark Wooding <mdw@distorted.org.uk>
Mon, 11 Mar 2024 13:04:04 +0000 (13:04 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 11 Mar 2024 13:04:04 +0000 (13:04 +0000)
test/bench.c
test/bench.h
test/tvec-bench.c

index 225d40c..7fedc9d 100644 (file)
@@ -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.
    *
index bca3b01..0645068 100644 (file)
@@ -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 -------------------------------------------------*/
index c81fd68..dda5713 100644 (file)
@@ -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);