diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-09-03 15:14:33 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-09-03 15:14:33 -0400 |
commit | b5e16fb14006c3813bd785c4c289dcc0f7e37b59 (patch) | |
tree | 2b51711bd2c7df2ec26be81e0b830329c9fc518d /bin | |
parent | 460d19baddd2ac077d2c06f090ac1db09e1730e6 (diff) |
add tool for measuring cycles/sec
Diffstat (limited to 'bin')
-rw-r--r-- | bin/cycles.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/bin/cycles.c b/bin/cycles.c new file mode 100644 index 0000000..4e5a078 --- /dev/null +++ b/bin/cycles.c | |||
@@ -0,0 +1,25 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdlib.h> | ||
3 | #include <unistd.h> | ||
4 | |||
5 | #include "cycles.h" | ||
6 | |||
7 | int main(int argc, char** argv) | ||
8 | { | ||
9 | cycles_t t1, t2; | ||
10 | int secs = 1; | ||
11 | |||
12 | if (argc > 1) { | ||
13 | secs = atoi(argv[1]); | ||
14 | if (secs <= 0) | ||
15 | secs = 1; | ||
16 | } | ||
17 | while (1) { | ||
18 | t1 = get_cycles(); | ||
19 | sleep(secs); | ||
20 | t2 = get_cycles(); | ||
21 | t2 -= t1; | ||
22 | printf("%.2f/sec\n", t2 / (double) secs); | ||
23 | } | ||
24 | return 0; | ||
25 | } | ||