From owner-svn-src-head@FreeBSD.ORG Sun Oct 24 09:14:22 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1C9BB106564A; Sun, 24 Oct 2010 09:14:22 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E499D8FC1A; Sun, 24 Oct 2010 09:14:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o9O9ELB9022929; Sun, 24 Oct 2010 09:14:21 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9O9ELh3022927; Sun, 24 Oct 2010 09:14:21 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201010240914.o9O9ELh3022927@svn.freebsd.org> From: Robert Watson Date: Sun, 24 Oct 2010 09:14:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214261 - head/tools/tools/syscall_timing X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Oct 2010 09:14:22 -0000 Author: rwatson Date: Sun Oct 24 09:14:21 2010 New Revision: 214261 URL: http://svn.freebsd.org/changeset/base/214261 Log: Add microbenchmark for create/unlink of a zero-byte file. Sponsored by: Google, Inc. MFC after: 2 weeks 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 Sun Oct 24 05:22:07 2010 (r214260) +++ head/tools/tools/syscall_timing/syscall_timing.c Sun Oct 24 09:14:21 2010 (r214261) @@ -260,6 +260,34 @@ test_socketpair_dgram(uintmax_t num, uin } uintmax_t +test_create_unlink(uintmax_t num, uintmax_t int_arg, const char *path) +{ + uintmax_t i; + int fd; + + (void)unlink(path); + fd = open(path, O_RDWR | O_CREAT, 0600); + if (fd < 0) + err(-1, "test_create_unlink: create: %s", path); + close(fd); + if (unlink(path) < 0) + err(-1, "test_create_unlink: unlink: %s", path); + benchmark_start(); + for (i = 0; i < num; i++) { + if (alarm_fired) + break; + fd = open(path, O_RDWR | O_CREAT, 0600); + if (fd < 0) + err(-1, "test_create_unlink: create: %s", path); + close(fd); + if (unlink(path) < 0) + err(-1, "test_create_unlink: unlink: %s", path); + } + benchmark_stop(); + return (i); +} + +uintmax_t test_open_close(uintmax_t num, uintmax_t int_arg, const char *path) { uintmax_t i; @@ -292,7 +320,7 @@ test_read(uintmax_t num, uintmax_t int_a fd = open(path, O_RDONLY); if (fd < 0) - err(-1, "test_open_close: %s", path); + err(-1, "test_open_read: %s", path); (void)pread(fd, buf, int_arg, 0); benchmark_start(); @@ -315,7 +343,7 @@ test_open_read_close(uintmax_t num, uint fd = open(path, O_RDONLY); if (fd < 0) - err(-1, "test_open_close: %s", path); + err(-1, "test_open_read_close: %s", path); (void)read(fd, buf, int_arg); close(fd); @@ -325,7 +353,7 @@ test_open_read_close(uintmax_t num, uint break; fd = open(path, O_RDONLY); if (fd < 0) - err(-1, "test_open_close: %s", path); + err(-1, "test_open_read_close: %s", path); (void)read(fd, buf, int_arg); close(fd); } @@ -587,6 +615,7 @@ static const struct test tests[] = { { "socketpair_dgram", test_socketpair_dgram }, { "socket_tcp", test_socket_stream, .t_int = PF_INET }, { "socket_udp", test_socket_dgram, .t_int = PF_INET }, + { "create_unlink", test_create_unlink, .t_flags = FLAG_PATH }, { "open_close", test_open_close, .t_flags = FLAG_PATH }, { "open_read_close_1", test_open_read_close, .t_flags = FLAG_PATH, .t_int = 1 },