summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2005-04-10 02:06:49 +0000
committerrwatson <rwatson@FreeBSD.org>2005-04-10 02:06:49 +0000
commitc5df80448a267ce23fd68d7f4fcb3025bc18eb51 (patch)
tree24afcdda7a0b35d2965d3038d2f204f7f109e83a
parent654c522ae858faf02e78aed1727928c971fb8112 (diff)
downloadFreeBSD-src-c5df80448a267ce23fd68d7f4fcb3025bc18eb51.zip
FreeBSD-src-c5df80448a267ce23fd68d7f4fcb3025bc18eb51.tar.gz
Centralize usage in usage(), and use in preference to fprintf().
List possible tests in usage(). When running a test, print the test name.
-rw-r--r--tools/tools/syscall_timing/syscall_timing.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/tools/tools/syscall_timing/syscall_timing.c b/tools/tools/syscall_timing/syscall_timing.c
index 5e44a94..3e4ca8d 100644
--- a/tools/tools/syscall_timing/syscall_timing.c
+++ b/tools/tools/syscall_timing/syscall_timing.c
@@ -128,16 +128,24 @@ test_socket(int num)
}
}
+static void
+usage(void)
+{
+
+ fprintf(stderr, "syscall_timing [iterations] [test]\n");
+ fprintf(stderr, "supported tests: getuid getppid clock_gettime "
+ "pipe socket\n");
+ exit(-1);
+}
+
int
main(int argc, char *argv[])
{
struct timespec ts_start, ts_end, ts_res;
int count;
- if (argc != 3) {
- fprintf(stderr, "syscall_timing [iterations] [test]\n");
- exit(-1);
- }
+ if (argc != 3)
+ usage();
count = atoi(argv[1]);
assert(clock_getres(CLOCK_REALTIME, &ts_res) == 0);
@@ -163,13 +171,13 @@ main(int argc, char *argv[])
assert(clock_gettime(CLOCK_REALTIME, &ts_start) == 0);
test_socket(count);
assert(clock_gettime(CLOCK_REALTIME, &ts_end) == 0);
- } else {
- fprintf(stderr, "syscal [iterations] [test]\n");
- exit(-1);
- }
+ } else
+ usage();
timespecsub(&ts_end, &ts_start);
+ printf("test: %s\n", argv[2]);
+
printf("%d.%09lu for %d iterations\n", ts_end.tv_sec,
ts_end.tv_nsec, count);
OpenPOWER on IntegriCloud