shithub: bench9

ref: 05188cb08b4304e34a7d822bb0f80ef5b780aa72
dir: bench9/b.h

View raw version
typedef struct B B;
typedef struct Bgr Bgr;
typedef struct Cns Cns;

enum {
	Kb = 1024ULL,
	Mb = 1024ULL*1024ULL,
	Gb = 1024ULL*1024ULL*1024ULL,
};

struct Cns {
	uvlong c;
	uvlong ns;
};

#pragma varargck type "σ" B*
#pragma varargck type "τ" Cns

struct B {
	uvlong n;
	uvlong tin;
	uvlong tout;
	uvlong step;
	uvlong t0;
	Cns tot, avg, med, min, max;
	Cns p[100];
	uvlong *c;
	int nc, ic;
	char *name;
};

struct Bgr {
	char *name;
	B **b;
	int nb;
};

/* private */
void benchstep(B *b);
void tstart(uvlong *c);
extern void (*tend)(uvlong *c);

/* public */
int benchwire(int cpu);

Bgr *benchinitgr(Bgr *gr, char *name);
B *benchadd(Bgr *gr, char *name);
#define benchin(b) do{ tstart(&(b)->tin); }while(0)
#define benchout(b) do{ tend(&(b)->tout); benchstep(b); }while(0)
void benchprintgr(Bgr *gr, int fd);
void benchfreegr(Bgr *gr);
void bseparator(int fd);

B *benchinit(B *b, char *name);
void benchprint(B **b, int nb, int fd);