Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Apr 2018 17:27:13 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r332625 - stable/11/tools/tools/syscall_timing
Message-ID:  <201804161727.w3GHRDnn031916@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Mon Apr 16 17:27:13 2018
New Revision: 332625
URL: https://svnweb.freebsd.org/changeset/base/332625

Log:
  MFC r325315:
  
  Add select(2) benchmark.  It takes four pointers; unfortunately it's
  somewhat heavy.

Modified:
  stable/11/tools/tools/syscall_timing/syscall_timing.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/tools/tools/syscall_timing/syscall_timing.c
==============================================================================
--- stable/11/tools/tools/syscall_timing/syscall_timing.c	Mon Apr 16 17:26:32 2018	(r332624)
+++ stable/11/tools/tools/syscall_timing/syscall_timing.c	Mon Apr 16 17:27:13 2018	(r332625)
@@ -177,7 +177,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)
 {
@@ -207,6 +206,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;
@@ -667,6 +691,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?201804161727.w3GHRDnn031916>