Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Nov 2017 12:13:02 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r325315 - head/tools/tools/syscall_timing
Message-ID:  <201711021213.vA2CD23H025832@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 },



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201711021213.vA2CD23H025832>