Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Nov 2018 11:46:12 +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: r340216 - head/tools/tools/syscall_timing
Message-ID:  <201811071146.wA7BkCgI038800@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Wed Nov  7 11:46:12 2018
New Revision: 340216
URL: https://svnweb.freebsd.org/changeset/base/340216

Log:
  Add benchmarks for lstat(2) and readlink(2).
  
  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	Wed Nov  7 11:14:22 2018	(r340215)
+++ head/tools/tools/syscall_timing/syscall_timing.c	Wed Nov  7 11:46:12 2018	(r340216)
@@ -335,6 +335,23 @@ test_getuid(uintmax_t num, uintmax_t int_arg __unused,
 }
 
 static uintmax_t
+test_lstat(uintmax_t num, uintmax_t int_arg __unused, const char *path)
+{
+	struct stat sb;
+	uintmax_t i;
+	int error;
+
+	benchmark_start();
+	BENCHMARK_FOREACH(i, num) {
+		error = lstat(path, &sb);
+		if (error != 0)
+			err(-1, "lstat");
+	}
+	benchmark_stop();
+	return (i);
+}
+
+static uintmax_t
 test_memcpy(uintmax_t num, uintmax_t int_arg, const char *path __unused)
 {
 	char buf[int_arg], buf2[int_arg];
@@ -824,6 +841,23 @@ test_socketpair_dgram(uintmax_t num, uintmax_t int_arg
 }
 
 static uintmax_t
+test_readlink(uintmax_t num, uintmax_t int_arg __unused, const char *path)
+{
+	char buf[PATH_MAX];
+	ssize_t rv;
+	uintmax_t i;
+
+	benchmark_start();
+	BENCHMARK_FOREACH(i, num) {
+		rv = readlink(path, buf, sizeof(buf));
+		if (rv < 0 && errno != EINVAL)
+			err(-1, "readlink");
+	}
+	benchmark_stop();
+	return (i);
+}
+
+static uintmax_t
 test_vfork(uintmax_t num, uintmax_t int_arg __unused, const char *path __unused)
 {
 	pid_t pid;
@@ -904,6 +938,7 @@ static const struct test tests[] = {
 	{ "getresuid", test_getresuid, .t_flags = 0 },
 	{ "gettimeofday", test_gettimeofday, .t_flags = 0 },
 	{ "getuid", test_getuid, .t_flags = 0 },
+	{ "lstat", test_lstat, .t_flags = FLAG_PATH },
 	{ "memcpy_1", test_memcpy, .t_flags = 0, .t_int = 1 },
 	{ "memcpy_10", test_memcpy, .t_flags = 0, .t_int = 10 },
 	{ "memcpy_100", test_memcpy, .t_flags = 0, .t_int = 100 },
@@ -962,6 +997,7 @@ static const struct test tests[] = {
 	{ "socketpair_dgram", test_socketpair_dgram, .t_flags = 0 },
 	{ "socket_tcp", test_socket_stream, .t_int = PF_INET },
 	{ "socket_udp", test_socket_dgram, .t_int = PF_INET },
+	{ "readlink", test_readlink, .t_flags = FLAG_PATH },
 	{ "vfork", test_vfork, .t_flags = 0 },
 	{ "vfork_exec", test_vfork_exec, .t_flags = 0 },
 };



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