ref: 721724916347c46df7cfa3105ac6fd1f6da652ed
dir: /bench.h/
typedef struct BItem BItem; typedef struct B B; // single benchmark function struct BItem { char *name; void (*fn)(B*); }; // 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 */ long *histo; /* histogram */ int nhisto; /* histogram size */ vlong overheadns; /* cost of doing 0 iters */ vlong overheadcy; /* cost of doing 0 iters, cycles */ BItem item; }; extern int NPROC; enum { KiB = 1024, MiB = 1024*KiB, GiB = 1024*MiB, }; #define BM(func) bench("func", func) // public api void benchinit(int, char**); void bench(char *name, void (*)(B*)); void benchitems(BItem[], int);