ref: 36ca89c4363a46ab0d7d2d562f92e92c4ba81063
dir: /bench.h/
typedef struct BItem BItem;
typedef struct BResult BResult;
typedef struct B B;
// single benchmark function
struct BItem
{
char *name;
void (*fn)(B*);
};
// result of benchmarking
struct BResult
{
int N;
vlong ns;
uvlong cycles;
vlong overhead;
};
// type passed to bench functions
struct B
{
int N;
vlong start; /* start ns */
vlong ns; /* duration */
uvlong scycles; /* start cycles */
uvlong ecycles; /* end cycles */
uvlong bcycles; /* best cycles */
vlong overheadns; /* cost of doing 0 iters */
vlong overheadcy; /* cost of doing 0 iters, cycles */
BItem item;
};
extern int NPROC;
#define BM(func) bench("func", func)
#define XBM(func, init) xbench("func", func, init)
// public api
void benchinit(int, char**);
void bench(char *name, void (*)(B*));
void xbench(char *name, void(*)(B*), void (*)(void));
void benchitems(BItem[], int);