From: Matthew Dillon Date: Mon, 13 Jul 2009 05:44:08 +0000 (-0700) Subject: SYSPERF - update pipe1, pipe2 X-Git-Tag: v2.3.2~8 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/92d10ba74984ccea4953cd6837ada357f1386042 SYSPERF - update pipe1, pipe2 * pipe1 now does a 1-second timing run. * pipe2 now does a 2-second timing run, just so it runs just a tad longer. --- diff --git a/test/sysperf/pipe1.c b/test/sysperf/pipe1.c index 50a2d686d3..9e06a6b3c8 100644 --- a/test/sysperf/pipe1.c +++ b/test/sysperf/pipe1.c @@ -11,8 +11,9 @@ main(int ac, char **av) { long long count = 0; long long max; - char c; + char c[1]; int j; + int loops; int fds[2]; printf("tests full duplex pipe 1write,2read,2write,1read loop\n"); @@ -25,8 +26,8 @@ main(int ac, char **av) * child process */ close(fds[0]); - while (read(fds[1], &c, 1) == 1) { - write(fds[1], &c, 1); + while (read(fds[1], c, sizeof(c)) == sizeof(c)) { + write(fds[1], c, sizeof(c)); } _exit(0); } else { @@ -34,12 +35,25 @@ main(int ac, char **av) * parent process. */ close(fds[1]); - write(fds[0], &c, 1); /* prime the caches */ - read(fds[0], &c, 1); + write(fds[0], c, sizeof(c)); /* prime the caches */ + read(fds[0], c, sizeof(c)); + + start_timing(); + for (j = 0; ; ++j) { + write(fds[0], c, sizeof(c)); + if (read(fds[0], c, sizeof(c)) != sizeof(c)) { + fprintf(stderr, "broken pipe during test\n"); + exit(1); + } + if ((j & 31) == 0 && stop_timing(0, NULL)) + break; + } + loops = j; + start_timing(); - for (j = 0; j < 100000; ++j) { - write(fds[0], &c, 1); - if (read(fds[0], &c, 1) != 1) { + for (j = 0; j < loops; ++j) { + write(fds[0], c, sizeof(c)); + if (read(fds[0], c, sizeof(c)) != sizeof(c)) { fprintf(stderr, "broken pipe during test\n"); exit(1); } diff --git a/test/sysperf/pipe2.c b/test/sysperf/pipe2.c index a5c130920e..e4b1b32e5a 100644 --- a/test/sysperf/pipe2.c +++ b/test/sysperf/pipe2.c @@ -105,6 +105,7 @@ main(int ac, char **av) break; } loops = j * 2 + 1; + loops *= 2; usleep(1000000 / 10); start_timing();