aboutsummaryrefslogtreecommitdiffstats
path: root/bin/cycles.c
blob: babd07304b3a27913301c8fa7f5ebd346932f028 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include "asm/cycles.h"

int main(int argc, char** argv)
{
	cycles_t t1, t2;
	int secs = 1;

	if (argc > 1) {
		secs = atoi(argv[1]);
		if (secs <= 0)
			secs = 1;
	}
	while (1) {
		t1 = get_cycles();
		sleep(secs);
		t2 = get_cycles();
		t2 -= t1;
		printf("%.2f/sec  %.2f/msec  %.2f/usec\n",
		       t2 / (double) secs,
		       t2 / (secs * 1000.0),
		       t2 / (secs * 1000000.0));
	}
	return 0;
}