4 # Copyright (c) 2015 EMC Corp.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 # Create 100.000 files of size 64k; a total of 6GB
37 sed '1,/^EOF/d' < $odir/$0 > $dir/tar.c
38 mycc -o tar -Wall -Wextra -O0 -g tar.c || exit 1
43 wdir=`dirname $diskimage`
45 [ `df -k $wdir | tail -1 | awk '{print $4}'` -lt \
46 $((6 * 1024 * 1024)) ] &&
47 echo "Not enough disk space on $wdir." && exit 0
49 for i in `jot $(sysctl -n hw.ncpu)`; do
50 /tmp/tar $wdir | ministat -n | tail -2 &
55 rm -rf /tmp/tar $wdir/tar.tmp
73 main(int argc, char *argv[])
75 struct timeval start, stop, diff;
82 errx(1, "Usage: %s <path>", argv[0]);
85 snprintf(path, sizeof(path), "%s/tar.tmp", argv[1]);
87 for (i = 0; i < 100; i++) {
88 snprintf(path, sizeof(path), "%s/tar.tmp/d%d", argv[1], i);
89 if (mkdir(path, 0777) == -1)
91 err(1, "mkdir(%s)", path);
92 for (j = 0; j < 100; j++) {
93 snprintf(path, sizeof(path), "%s/tar.tmp/d%d/d%d",
95 if (mkdir(path, 0777) == -1)
97 err(1, "mkdir(%s)", path);
100 for (i = 0; i < 100; i++) {
101 for (j = 0; j < 100; j++) {
102 for (k = 0; k < 10; k++) {
103 snprintf(path, sizeof(path),
104 "%s/tar.tmp/d%d/d%d/f%d", argv[1], i, j, k);
105 gettimeofday(&start, NULL);
107 if ((fd = open(path, O_RDWR | O_CREAT, 0644))
109 err(1, "open(%s)", path);
110 write(fd, buf, sizeof(buf));
112 gettimeofday(&stop, NULL);
113 timersub(&stop, &start, &diff);
114 usec = ((uint64_t)1000000 *
115 diff.tv_sec + diff.tv_usec);
118 fprintf(stdout, "%.3f %s\n",
119 (double)usec / 1000000, path);
122 if (time(NULL) - stime > RUNTIME) {
123 fprintf(stderr, "Timed out at %s.\n", path);
128 // fprintf(stderr, "%.3f %s : FAIL\n", (double)mx / 1000000, path);