From e854cfb828a05f5345be16e10afb40995461e130 Mon Sep 17 00:00:00 2001 From: trasz Date: Thu, 2 Nov 2017 12:13:02 +0000 Subject: [PATCH] Add select(2) benchmark. It takes four pointers; unfortunately it's somewhat heavy. Obtained from: CheriBSD MFC after: 2 weeks Sponsored by: DARPA, AFRL --- tools/tools/syscall_timing/syscall_timing.c | 27 ++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tools/tools/syscall_timing/syscall_timing.c b/tools/tools/syscall_timing/syscall_timing.c index 6a6ea4ef951b..99da5f6de6d0 100644 --- a/tools/tools/syscall_timing/syscall_timing.c +++ b/tools/tools/syscall_timing/syscall_timing.c @@ -178,7 +178,6 @@ test_getpriority(uintmax_t num, uintmax_t int_arg, const char *path) return (i); } - uintmax_t test_pipe(uintmax_t num, uintmax_t int_arg, const char *path) { @@ -207,6 +206,31 @@ test_pipe(uintmax_t num, uintmax_t int_arg, const char *path) return (i); } +uintmax_t +test_select(uintmax_t num, uintmax_t int_arg, const char *path) +{ + fd_set readfds, writefds, exceptfds; + struct timeval tv; + uintmax_t i; + int error; + + FD_ZERO(&readfds); + FD_ZERO(&writefds); + FD_ZERO(&exceptfds); + + tv.tv_sec = 0; + tv.tv_usec = 0; + + benchmark_start(); + for (i = 0; i < num; i++) { + if (alarm_fired) + break; + (void)select(0, &readfds, &writefds, &exceptfds, &tv); + } + benchmark_stop(); + return (i); +} + uintmax_t test_socket_stream(uintmax_t num, uintmax_t int_arg, const char *path) { @@ -653,6 +677,7 @@ static const struct test tests[] = { { "gettimeofday", test_gettimeofday }, { "getpriority", test_getpriority }, { "pipe", test_pipe }, + { "select", test_select }, { "socket_local_stream", test_socket_stream, .t_int = PF_LOCAL }, { "socket_local_dgram", test_socket_dgram, .t_int = PF_LOCAL }, { "socketpair_stream", test_socketpair_stream },