summaryrefslogtreecommitdiff
path: root/bench/bench.h
blob: f1b6016a8d5f85bc42fba2f5156a5bac29c951b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
static inline unsigned long long int rdtsc(void)
{
	unsigned int low, high;

	__asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high));
	return ((unsigned long long int)high << 32) | low;
}

#define NREPS 1000

#define TIME(x,y) \
{ \
	int i;				\
	unsigned long bstart, bend;	\
	bstart = rdtsc();		\
	for (i=0; i<NREPS; i++)		\
		x;			\
	bend = rdtsc();			\
	printf(y ": %ld cycles\n", ((bend-bstart)/NREPS)); \
}