aboutsummaryrefslogtreecommitdiff
path: root/tools/tools/syscall_timing
diff options
context:
space:
mode:
authorRobert Watson <rwatson@FreeBSD.org>2005-04-10 02:06:49 +0000
committerRobert Watson <rwatson@FreeBSD.org>2005-04-10 02:06:49 +0000
commit11853de0a109d330dccb4b9b8f594516302e8923 (patch)
tree24afcdda7a0b35d2965d3038d2f204f7f109e83a /tools/tools/syscall_timing
parente5dd4df84cf1ca0360e111bc6ca4cbbad0b22bb7 (diff)
downloadsrc-11853de0a109d330dccb4b9b8f594516302e8923.tar.gz
src-11853de0a109d330dccb4b9b8f594516302e8923.zip
Centralize usage in usage(), and use in preference to fprintf().
List possible tests in usage(). When running a test, print the test name.
Notes
Notes: svn path=/head/; revision=144850
Diffstat (limited to 'tools/tools/syscall_timing')
-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 5e44a94fe650..3e4ca8dceca9 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);