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 | |
| parent | 460d19baddd2ac077d2c06f090ac1db09e1730e6 (diff) | |
add tool for measuring cycles/sec
| -rw-r--r-- | Makefile | 5 | ||||
| -rw-r--r-- | bin/cycles.c | 25 |
2 files changed, 29 insertions, 1 deletions
| @@ -19,7 +19,7 @@ LIBS= ./liblitmus.a | |||
| 19 | LIB_OBJ= litmus.o syscalls.o sched_trace.o task.o kernel_iface.o | 19 | LIB_OBJ= litmus.o syscalls.o sched_trace.o task.o kernel_iface.o |
| 20 | 20 | ||
| 21 | TARGETS = run rt_launch liblitmus.a \ | 21 | TARGETS = run rt_launch liblitmus.a \ |
| 22 | wait_test np_test stdump mode_test base_task base_mt_task release_ts | 22 | wait_test np_test stdump mode_test base_task base_mt_task release_ts cycles |
| 23 | 23 | ||
| 24 | vpath %.h include/ | 24 | vpath %.h include/ |
| 25 | vpath %.c src/ bin/ | 25 | vpath %.c src/ bin/ |
| @@ -55,6 +55,9 @@ release_ts: liblitmus.a litmus.h release_ts.o | |||
| 55 | stdump: liblitmus.a litmus.h sched_trace.h stdump.o | 55 | stdump: liblitmus.a litmus.h sched_trace.h stdump.o |
| 56 | ${CC} ${CFLAGS} -o stdump stdump.o ${LIBS} | 56 | ${CC} ${CFLAGS} -o stdump stdump.o ${LIBS} |
| 57 | 57 | ||
| 58 | cycles: cycles.o | ||
| 59 | ${CC} ${CFLAGS} -o cycles cycles.o | ||
| 60 | |||
| 58 | liblitmus.a: ${LIB_OBJ} litmus.h | 61 | liblitmus.a: ${LIB_OBJ} litmus.h |
| 59 | ${AR} rcs liblitmus.a ${LIB_OBJ} | 62 | ${AR} rcs liblitmus.a ${LIB_OBJ} |
| 60 | 63 | ||
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 | } | ||
