svn commit: r325315 - head/tools/tools/syscall_timing

Edward Tomasz Napierala trasz at FreeBSD.org
Thu Nov 2 12:13:03 UTC 2017


Author: trasz
Date: Thu Nov  2 12:13:02 2017
New Revision: 325315
URL: https://svnweb.freebsd.org/changeset/base/325315

Log:
  Add select(2) benchmark.  It takes four pointers; unfortunately it's
  somewhat heavy.
  
  Obtained from:	CheriBSD
  MFC after:	2 weeks
  Sponsored by:	DARPA, AFRL

Modified:
  head/tools/tools/syscall_timing/syscall_timing.c

Modified: head/tools/tools/syscall_timing/syscall_timing.c
==============================================================================
--- head/tools/tools/syscall_timing/syscall_timing.c	Thu Nov  2 12:12:18 2017	(r325314)
+++ head/tools/tools/syscall_timing/syscall_timing.c	Thu Nov  2 12:13:02 2017	(r325315)
@@ -178,7 +178,6 @@ test_getpriority(uintmax_t num, uintmax_t int_arg, con
 	return (i);
 }
 
-
 uintmax_t
 test_pipe(uintmax_t num, uintmax_t int_arg, const char *path)
 {
@@ -208,6 +207,31 @@ test_pipe(uintmax_t num, uintmax_t int_arg, const char
 }
 
 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)
 {
 	uintmax_t i;
@@ -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 },


More information about the svn-src-all mailing list