/*----- Header files ------------------------------------------------------*/
+#include <time.h>
+
#ifndef MLIB_BITS_H
# include "bits.h"
#endif
#define BTF_TIMEOK 1u /* @s@ ad @ns@ slots are value */
#define BTF_CYOK 2u /* @cy@ slot is valid */
#define BTF_ANY (BTF_TIMEOK | BTF_CYOK) /* some part is useful */
- kludge64 s; uint32 ns; /* real time, seconds and nanos */
+ union {
+ struct { kludge64 s; uint32 ns; } ts; /* @struct timespec@-ish */
+ clock_t clk; /* @clock@ */
+ kludge64 rawns; /* raw nanosecond count */
+ } t; /* time */
kludge64 cy; /* count of CPU cycles */
};
void (*describe)(struct bench_timer */*bt*/, dstr */*d*/);
/* Write a description of the timer to @d@. */
- void (*now)(struct bench_timer */*bt*/, struct bench_time */*t_out*/);
- /* Fill in @*t_out@ with the current time. v*/
+ int (*now)(struct bench_timer */*bt*/, struct bench_time */*t_out*/,
+ unsigned /*f*/);
+#define BTF_T0 0u /* fetching first time of a pair */
+#define BTF_T1 1u /* fetching second time of a pair */
+ /* Fill in @*t_out@ with the current time. Return zero on success
+ * %%\emph{or} permanent failure; return %$-1$% on temporary failure.
+ */
+
+ void (*diff)(struct bench_timer */*bt*/,
+ struct bench_timing */*delta_out*/,
+ const struct bench_time */*t0*/,
+ const struct bench_time */*t1*/);
+ /* Subtract the time @t0@ from the time @t1@, leaving the result in
+ * @*delta_out@, setting flags as appropriate.
+ */
void (*destroy)(struct bench_timer */*bt*/);
/* Release the timer and any resources it holds. */