11 'ds / \\h'\\w' 'u-\\w'/'u'/
12 'ds /* \\h'\\w' 'u-\\w'/'u'/*
21 'tl '\s14\f3\\*(=F\fP\s0'\\*(=H'\f3\s14\\*(=F\fP\s0'
24 \f2\s12\h'\\n(.lu-\w'\\*(=f'u'\\*(=f\fP\s0\h'|0u'
32 'ie o 'tl '\f2\\*(=M''Page % of \\*(=G\fP'
33 'el 'tl '\f2Page % of \\*(=G''\\*(=M\fP'
60 \f2\s14\h'\\n(.lu-\w'\\$1'u'\\$1\fP\s0\h'|0u'\c
61 .if r x .if \\nx .if d =F .tm \\$1 \\*(=F \\n%
65 .if r x .if \\nx .if d =F .tm \\$1 \\*(=F \\n%
74 .\" Copyright (c) 1985 The Regents of the University of California.
75 .\" All rights reserved.
77 .\" Redistribution and use in source and binary forms, with or without
78 .\" modification, are permitted provided that the following conditions
80 .\" 1. Redistributions of source code must retain the above copyright
81 .\" notice, this list of conditions and the following disclaimer.
82 .\" 2. Redistributions in binary form must reproduce the above copyright
83 .\" notice, this list of conditions and the following disclaimer in the
84 .\" documentation and/or other materials provided with the distribution.
85 .\" 3. All advertising materials mentioning features or use of this software
86 .\" must display the following acknowledgement:
87 .\" This product includes software developed by the University of
88 .\" California, Berkeley and its contributors.
89 .\" 4. Neither the name of the University nor the names of its contributors
90 .\" may be used to endorse or promote products derived from this software
91 .\" without specific prior written permission.
93 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
94 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
95 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
96 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
97 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
98 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
99 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
100 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
101 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
102 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
105 .\" @(#)a1.t 5.1 (Berkeley) 4/17/91
107 .ds RH Appendix A \- Benchmark sources
118 \s+2Appendix A \- Benchmark sources\s-2
120 The programs shown here run under 4.2 with only routines
121 from the standard libraries. When run under 4.1 they were augmented
122 with a \fIgetpagesize\fP routine and a copy of the \fIrandom\fP
123 function from the C library. The \fIvforks\fP and \fIvexecs\fP
124 programs are constructed from the \fIforks\fP and \fIexecs\fP programs,
125 respectively, by substituting calls to \fIfork\fP with calls to
131 \fI\h'\w' 'u-\w'/'u'/\fP\fI*\fP\c\c
134 \fI*\fP System call overhead benchmark\&.
135 \fI*\fP\fI\h'\w' 'u-\w'/'u'/\fP\c
140 \h'|11n'\*(+Kchar\*(-K \fI*\fPargv[];
142 \h'|11n'\*(+Kregister\*(-K \*(+Kint\*(-K ncalls;
144 \h'|11n'\*(+Kif\*(-K (argc < 2) \*(+K{\*(-K
145 \h'|21n'printf("usage: %s #syscalls\en", argv[0]);
148 \h'|11n'ncalls = atoi(argv[1]);
149 \h'|11n'\*(+Kwhile\*(-K (ncalls\*-\*- > 0)
150 \h'|21n'(\*(+Kvoid\*(-K) getpid();
159 \fI\h'\w' 'u-\w'/'u'/\fP\fI*\fP\c\c
162 \fI*\fP Context switching benchmark\&.
164 \fI*\fP Force system to context switch 2\fI*\fPnsigs
165 \fI*\fP times by forking and exchanging signals\&.
166 \fI*\fP To calculate system overhead for a context
167 \fI*\fP switch, the signocsw program must be run
168 \fI*\fP with nsigs\&. Overhead is then estimated by
169 \fI*\fP\h'|11n't1 = time csw <n>
170 \fI*\fP\h'|11n't2 = time signocsw <n>
171 \fI*\fP\h'|11n'overhead = t1 \*- 2 \fI*\fP t2;
172 \fI*\fP\fI\h'\w' 'u-\w'/'u'/\fP\c
175 \*(+K#include\*(-K <signal\&.h>
177 \*(+Kint\*(-K\h'|11n'sigsub();
178 \*(+Kint\*(-K\h'|11n'otherpid;
179 \*(+Kint\*(-K\h'|11n'nsigs;
183 \h'|11n'\*(+Kchar\*(-K \fI*\fPargv[];
185 \h'|11n'\*(+Kint\*(-K pid;
187 \h'|11n'\*(+Kif\*(-K (argc < 2) \*(+K{\*(-K
188 \h'|21n'printf("usage: %s nsignals\en", argv[0]);
191 \h'|11n'nsigs = atoi(argv[1]);
192 \h'|11n'signal(SIGALRM, sigsub);
193 \h'|11n'otherpid = getpid();
194 \h'|11n'pid = fork();
195 \h'|11n'\*(+Kif\*(-K (pid != 0) \*(+K{\*(-K
196 \h'|21n'otherpid = pid;
197 \h'|21n'kill(otherpid, SIGALRM);
199 \h'|11n'\*(+Kfor\*(-K (;;)
209 \h'|11n'signal(SIGALRM, sigsub);
210 \h'|11n'kill(otherpid, SIGALRM);
211 \h'|11n'\*(+Kif\*(-K (\*-\*-nsigs <= 0)
221 \fI\h'\w' 'u-\w'/'u'/\fP\fI*\fP\c\c
224 \fI*\fP Signal without context switch benchmark\&.
225 \fI*\fP\fI\h'\w' 'u-\w'/'u'/\fP\c
228 \*(+K#include\*(-K <signal\&.h>
230 \*(+Kint\*(-K\h'|11n'pid;
231 \*(+Kint\*(-K\h'|11n'nsigs;
232 \*(+Kint\*(-K\h'|11n'sigsub();
236 \h'|11n'\*(+Kchar\*(-K \fI*\fPargv[];
238 \h'|11n'\*(+Kregister\*(-K \*(+Kint\*(-K i;
240 \h'|11n'\*(+Kif\*(-K (argc < 2) \*(+K{\*(-K
241 \h'|21n'printf("usage: %s nsignals\en", argv[0]);
244 \h'|11n'nsigs = atoi(argv[1]);
245 \h'|11n'signal(SIGALRM, sigsub);
246 \h'|11n'pid = getpid();
247 \h'|11n'\*(+Kfor\*(-K (i = 0; i < nsigs; i++)
248 \h'|21n'kill(pid, SIGALRM);
257 \h'|11n'signal(SIGALRM, sigsub);
266 \fI\h'\w' 'u-\w'/'u'/\fP\fI*\fP\c\c
269 \fI*\fP IPC benchmark,
270 \fI*\fP write to self using pipes\&.
271 \fI*\fP\fI\h'\w' 'u-\w'/'u'/\fP\c
277 \h'|11n'\*(+Kchar\*(-K \fI*\fPargv[];
279 \h'|11n'\*(+Kchar\*(-K buf[512];
280 \h'|11n'\*(+Kint\*(-K fd[2], msgsize;
281 \h'|11n'\*(+Kregister\*(-K \*(+Kint\*(-K i, iter;
283 \h'|11n'\*(+Kif\*(-K (argc < 3) \*(+K{\*(-K
284 \h'|21n'printf("usage: %s iterations message\*-size\en", argv[0]);
287 \h'|11n'argc\*-\*-, argv++;
288 \h'|11n'iter = atoi(\fI*\fPargv);
289 \h'|11n'argc\*-\*-, argv++;
290 \h'|11n'msgsize = atoi(\fI*\fPargv);
291 \h'|11n'\*(+Kif\*(-K (msgsize > \*(+Ksizeof\*(-K (buf) || msgsize <= 0) \*(+K{\*(-K
292 \h'|21n'printf("%s: Bad message size\&.\en", \fI*\fPargv);
295 \h'|11n'\*(+Kif\*(-K (pipe(fd) < 0) \*(+K{\*(-K
296 \h'|21n'perror("pipe");
299 \h'|11n'\*(+Kfor\*(-K (i = 0; i < iter; i++) \*(+K{\*(-K
300 \h'|21n'write(fd[1], buf, msgsize);
301 \h'|21n'read(fd[0], buf, msgsize);
311 \fI\h'\w' 'u-\w'/'u'/\fP\fI*\fP\c\c
314 \fI*\fP IPC benchmarkl,
315 \fI*\fP write and discard using pipes\&.
316 \fI*\fP\fI\h'\w' 'u-\w'/'u'/\fP\c
322 \h'|11n'\*(+Kchar\*(-K \fI*\fPargv[];
324 \h'|11n'\*(+Kchar\*(-K buf[512];
325 \h'|11n'\*(+Kint\*(-K fd[2], msgsize;
326 \h'|11n'\*(+Kregister\*(-K \*(+Kint\*(-K i, iter;
328 \h'|11n'\*(+Kif\*(-K (argc < 3) \*(+K{\*(-K
329 \h'|21n'printf("usage: %s iterations message\*-size\en", argv[0]);
332 \h'|11n'argc\*-\*-, argv++;
333 \h'|11n'iter = atoi(\fI*\fPargv);
334 \h'|11n'argc\*-\*-, argv++;
335 \h'|11n'msgsize = atoi(\fI*\fPargv);
336 \h'|11n'\*(+Kif\*(-K (msgsize > \*(+Ksizeof\*(-K (buf) || msgsize <= 0) \*(+K{\*(-K
337 \h'|21n'printf("%s: Bad message size\&.\en", \fI*\fPargv);
340 \h'|11n'\*(+Kif\*(-K (pipe(fd) < 0) \*(+K{\*(-K
341 \h'|21n'perror("pipe");
344 \h'|11n'\*(+Kif\*(-K (fork() == 0)
345 \h'|21n'\*(+Kfor\*(-K (i = 0; i < iter; i++)
346 \h'|31n'read(fd[0], buf, msgsize);
347 \h'|11n'\*(+Kelse\*(-K
348 \h'|21n'\*(+Kfor\*(-K (i = 0; i < iter; i++)
349 \h'|31n'write(fd[1], buf, msgsize);
358 \fI\h'\w' 'u-\w'/'u'/\fP\fI*\fP\c\c
361 \fI*\fP IPC benchmark,
362 \fI*\fP read and reply using pipes\&.
364 \fI*\fP Process forks and exchanges messages
365 \fI*\fP over a pipe in a request\*-response fashion\&.
366 \fI*\fP\fI\h'\w' 'u-\w'/'u'/\fP\c
372 \h'|11n'\*(+Kchar\*(-K \fI*\fPargv[];
374 \h'|11n'\*(+Kchar\*(-K buf[512];
375 \h'|11n'\*(+Kint\*(-K fd[2], fd2[2], msgsize;
376 \h'|11n'\*(+Kregister\*(-K \*(+Kint\*(-K i, iter;
378 \h'|11n'\*(+Kif\*(-K (argc < 3) \*(+K{\*(-K
379 \h'|21n'printf("usage: %s iterations message\*-size\en", argv[0]);
382 \h'|11n'argc\*-\*-, argv++;
383 \h'|11n'iter = atoi(\fI*\fPargv);
384 \h'|11n'argc\*-\*-, argv++;
385 \h'|11n'msgsize = atoi(\fI*\fPargv);
386 \h'|11n'\*(+Kif\*(-K (msgsize > \*(+Ksizeof\*(-K (buf) || msgsize <= 0) \*(+K{\*(-K
387 \h'|21n'printf("%s: Bad message size\&.\en", \fI*\fPargv);
390 \h'|11n'\*(+Kif\*(-K (pipe(fd) < 0) \*(+K{\*(-K
391 \h'|21n'perror("pipe");
394 \h'|11n'\*(+Kif\*(-K (pipe(fd2) < 0) \*(+K{\*(-K
395 \h'|21n'perror("pipe");
398 \h'|11n'\*(+Kif\*(-K (fork() == 0)
399 \h'|21n'\*(+Kfor\*(-K (i = 0; i < iter; i++) \*(+K{\*(-K
400 \h'|31n'read(fd[0], buf, msgsize);
401 \h'|31n'write(fd2[1], buf, msgsize);
403 \h'|11n'\*(+Kelse\*(-K
404 \h'|21n'\*(+Kfor\*(-K (i = 0; i < iter; i++) \*(+K{\*(-K
405 \h'|31n'write(fd[1], buf, msgsize);
406 \h'|31n'read(fd2[0], buf, msgsize);
416 \fI\h'\w' 'u-\w'/'u'/\fP\fI*\fP\c\c
419 \fI*\fP Benchmark program to calculate fork+wait
420 \fI*\fP overhead (approximately)\&. Process
421 \fI*\fP forks and exits while parent waits\&.
422 \fI*\fP The time to run this program is used
423 \fI*\fP in calculating exec overhead\&.
424 \fI*\fP\fI\h'\w' 'u-\w'/'u'/\fP\c
430 \h'|11n'\*(+Kchar\*(-K \fI*\fPargv[];
432 \h'|11n'\*(+Kregister\*(-K \*(+Kint\*(-K nforks, i;
433 \h'|11n'\*(+Kchar\*(-K \fI*\fPcp;
434 \h'|11n'\*(+Kint\*(-K pid, child, status, brksize;
436 \h'|11n'\*(+Kif\*(-K (argc < 2) \*(+K{\*(-K
437 \h'|21n'printf("usage: %s number\*-of\*-forks sbrk\*-size\en", argv[0]);
440 \h'|11n'nforks = atoi(argv[1]);
441 \h'|11n'\*(+Kif\*(-K (nforks < 0) \*(+K{\*(-K
442 \h'|21n'printf("%s: bad number of forks\en", argv[1]);
445 \h'|11n'brksize = atoi(argv[2]);
446 \h'|11n'\*(+Kif\*(-K (brksize < 0) \*(+K{\*(-K
447 \h'|21n'printf("%s: bad size to sbrk\en", argv[2]);
450 \h'|11n'cp = (\*(+Kchar\*(-K \fI*\fP)sbrk(brksize);
451 \h'|11n'\*(+Kif\*(-K ((\*(+Kint\*(-K)cp == \*-1) \*(+K{\*(-K
452 \h'|21n'perror("sbrk");
455 \h'|11n'\*(+Kfor\*(-K (i = 0; i < brksize; i += 1024)
457 \h'|11n'\*(+Kwhile\*(-K (nforks\*-\*- > 0) \*(+K{\*(-K
458 \h'|21n'child = fork();
459 \h'|21n'\*(+Kif\*(-K (child == \*-1) \*(+K{\*(-K
460 \h'|31n'perror("fork");
463 \h'|21n'\*(+Kif\*(-K (child == 0)
464 \h'|31n'\*_exit(\*-1);
465 \h'|21n'\*(+Kwhile\*(-K ((pid = wait(&status)) != \*-1 && pid != child)
477 \fI\h'\w' 'u-\w'/'u'/\fP\fI*\fP\c\c
480 \fI*\fP Benchmark program to calculate exec
481 \fI*\fP overhead (approximately)\&. Process
482 \fI*\fP forks and execs "null" test program\&.
483 \fI*\fP The time to run the fork program should
484 \fI*\fP then be deducted from this one to
485 \fI*\fP estimate the overhead for the exec\&.
486 \fI*\fP\fI\h'\w' 'u-\w'/'u'/\fP\c
492 \h'|11n'\*(+Kchar\*(-K \fI*\fPargv[];
494 \h'|11n'\*(+Kregister\*(-K \*(+Kint\*(-K nexecs, i;
495 \h'|11n'\*(+Kchar\*(-K \fI*\fPcp, \fI*\fPsbrk();
496 \h'|11n'\*(+Kint\*(-K pid, child, status, brksize;
498 \h'|11n'\*(+Kif\*(-K (argc < 3) \*(+K{\*(-K
499 \h'|21n'printf("usage: %s number\*-of\*-execs sbrk\*-size job\*-name\en",
503 \h'|11n'nexecs = atoi(argv[1]);
504 \h'|11n'\*(+Kif\*(-K (nexecs < 0) \*(+K{\*(-K
505 \h'|21n'printf("%s: bad number of execs\en", argv[1]);
508 \h'|11n'brksize = atoi(argv[2]);
509 \h'|11n'\*(+Kif\*(-K (brksize < 0) \*(+K{\*(-K
510 \h'|21n'printf("%s: bad size to sbrk\en", argv[2]);
513 \h'|11n'cp = sbrk(brksize);
514 \h'|11n'\*(+Kif\*(-K ((\*(+Kint\*(-K)cp == \*-1) \*(+K{\*(-K
515 \h'|21n'perror("sbrk");
518 \h'|11n'\*(+Kfor\*(-K (i = 0; i < brksize; i += 1024)
520 \h'|11n'\*(+Kwhile\*(-K (nexecs\*-\*- > 0) \*(+K{\*(-K
521 \h'|21n'child = fork();
522 \h'|21n'\*(+Kif\*(-K (child == \*-1) \*(+K{\*(-K
523 \h'|31n'perror("fork");
526 \h'|21n'\*(+Kif\*(-K (child == 0) \*(+K{\*(-K
527 \h'|31n'execv(argv[3], argv);
528 \h'|31n'perror("execv");
529 \h'|31n'\*_exit(\*-1);
531 \h'|21n'\*(+Kwhile\*(-K ((pid = wait(&status)) != \*-1 && pid != child)
543 \fI\h'\w' 'u-\w'/'u'/\fP\fI*\fP\c\c
546 \fI*\fP Benchmark "null job" program\&.
547 \fI*\fP\fI\h'\w' 'u-\w'/'u'/\fP\c
553 \h'|11n'\*(+Kchar\*(-K \fI*\fPargv[];
565 \fI\h'\w' 'u-\w'/'u'/\fP\fI*\fP\c\c
568 \fI*\fP Benchmark "null big job" program\&.
569 \fI*\fP\fI\h'\w' 'u-\w'/'u'/\fP\c
572 \fI\h'\w' 'u-\w'/'u'/\fP\fI*\fP\c\c
574 250 here is intended to approximate vi\'s text+data size \fI*\fP\fI\h'\w' 'u-\w'/'u'/\fP\c
577 \*(+Kchar\*(-K\h'|11n'space[1024 \fI*\fP 250] = "force into data segment";
581 \h'|11n'\*(+Kchar\*(-K \fI*\fPargv[];
594 \fI\h'\w' 'u-\w'/'u'/\fP\fI*\fP\c\c
597 \fI*\fP Sequential page access benchmark\&.
598 \fI*\fP\fI\h'\w' 'u-\w'/'u'/\fP\c
601 \*(+K#include\*(-K <sys\fI\h'\w' 'u-\w'/'u'/\fPvadvise\&.h>
603 \*(+Kchar\*(-K\h'|11n'\fI*\fPvalloc();
607 \h'|11n'\*(+Kchar\*(-K \fI*\fPargv[];
609 \h'|11n'\*(+Kregister\*(-K i, niter;
610 \h'|11n'\*(+Kregister\*(-K \*(+Kchar\*(-K \fI*\fPpf, \fI*\fPlastpage;
611 \h'|11n'\*(+Kint\*(-K npages = 4096, pagesize, vflag = 0;
612 \h'|11n'\*(+Kchar\*(-K \fI*\fPpages, \fI*\fPname;
614 \h'|11n'name = argv[0];
615 \h'|11n'argc\*-\*-, argv++;
617 \h'|11n'\*(+Kif\*(-K (argc < 1) \*(+K{\*(-K
619 \h'|21n'printf("usage: %s [ \*-v ] [ \*-p #pages ] niter\en", name);
622 \h'|11n'\*(+Kif\*(-K (strcmp(\fI*\fPargv, "\*-p") == 0) \*(+K{\*(-K
623 \h'|21n'argc\*-\*-, argv++;
624 \h'|21n'\*(+Kif\*(-K (argc < 1)
625 \h'|31n'\*(+Kgoto\*(-K usage;
626 \h'|21n'npages = atoi(\fI*\fPargv);
627 \h'|21n'\*(+Kif\*(-K (npages <= 0) \*(+K{\*(-K
628 \h'|31n'printf("%s: Bad page count\&.\en", \fI*\fPargv);
631 \h'|21n'argc\*-\*-, argv++;
632 \h'|21n'\*(+Kgoto\*(-K again;
634 \h'|11n'\*(+Kif\*(-K (strcmp(\fI*\fPargv, "\*-v") == 0) \*(+K{\*(-K
635 \h'|21n'argc\*-\*-, argv++;
637 \h'|21n'\*(+Kgoto\*(-K again;
639 \h'|11n'niter = atoi(\fI*\fPargv);
640 \h'|11n'pagesize = getpagesize();
641 \h'|11n'pages = valloc(npages \fI*\fP pagesize);
642 \h'|11n'\*(+Kif\*(-K (pages == (\*(+Kchar\*(-K \fI*\fP)0) \*(+K{\*(-K
643 \h'|21n'printf("Can\'t allocate %d pages (%2\&.1f megabytes)\&.\en",
644 \h'|21n' npages, (npages \fI*\fP pagesize) \fI\h'\w' 'u-\w'/'u'/\fP (1024\&. \fI*\fP 1024\&.));
647 \h'|11n'lastpage = pages + (npages \fI*\fP pagesize);
648 \h'|11n'\*(+Kif\*(-K (vflag)
649 \h'|21n'vadvise(VA\*_SEQL);
650 \h'|11n'\*(+Kfor\*(-K (i = 0; i < niter; i++)
651 \h'|21n'\*(+Kfor\*(-K (pf = pages; pf < lastpage; pf += pagesize)
652 \h'|31n'\fI*\fPpf = 1;
661 \fI\h'\w' 'u-\w'/'u'/\fP\fI*\fP\c\c
664 \fI*\fP Random page access benchmark\&.
665 \fI*\fP\fI\h'\w' 'u-\w'/'u'/\fP\c
668 \*(+K#include\*(-K <sys\fI\h'\w' 'u-\w'/'u'/\fPvadvise\&.h>
670 \*(+Kchar\*(-K\h'|11n'\fI*\fPvalloc();
671 \*(+Kint\*(-K\h'|11n'rand();
675 \h'|11n'\*(+Kchar\*(-K \fI*\fPargv[];
677 \h'|11n'\*(+Kregister\*(-K \*(+Kint\*(-K npages = 4096, pagesize, pn, i, niter;
678 \h'|11n'\*(+Kint\*(-K vflag = 0, debug = 0;
679 \h'|11n'\*(+Kchar\*(-K \fI*\fPpages, \fI*\fPname;
681 \h'|11n'name = argv[0];
682 \h'|11n'argc\*-\*-, argv++;
684 \h'|11n'\*(+Kif\*(-K (argc < 1) \*(+K{\*(-K
686 \h'|21n'printf("usage: %s [ \*-d ] [ \*-v ] [ \*-p #pages ] niter\en", name);
689 \h'|11n'\*(+Kif\*(-K (strcmp(\fI*\fPargv, "\*-p") == 0) \*(+K{\*(-K
690 \h'|21n'argc\*-\*-, argv++;
691 \h'|21n'\*(+Kif\*(-K (argc < 1)
692 \h'|31n'\*(+Kgoto\*(-K usage;
693 \h'|21n'npages = atoi(\fI*\fPargv);
694 \h'|21n'\*(+Kif\*(-K (npages <= 0) \*(+K{\*(-K
695 \h'|31n'printf("%s: Bad page count\&.\en", \fI*\fPargv);
698 \h'|21n'argc\*-\*-, argv++;
699 \h'|21n'\*(+Kgoto\*(-K again;
701 \h'|11n'\*(+Kif\*(-K (strcmp(\fI*\fPargv, "\*-v") == 0) \*(+K{\*(-K
702 \h'|21n'argc\*-\*-, argv++;
704 \h'|21n'\*(+Kgoto\*(-K again;
706 \h'|11n'\*(+Kif\*(-K (strcmp(\fI*\fPargv, "\*-d") == 0) \*(+K{\*(-K
707 \h'|21n'argc\*-\*-, argv++;
709 \h'|21n'\*(+Kgoto\*(-K again;
711 \h'|11n'niter = atoi(\fI*\fPargv);
712 \h'|11n'pagesize = getpagesize();
713 \h'|11n'pages = valloc(npages \fI*\fP pagesize);
714 \h'|11n'\*(+Kif\*(-K (pages == (\*(+Kchar\*(-K \fI*\fP)0) \*(+K{\*(-K
715 \h'|21n'printf("Can\'t allocate %d pages (%2\&.1f megabytes)\&.\en",
716 \h'|21n' npages, (npages \fI*\fP pagesize) \fI\h'\w' 'u-\w'/'u'/\fP (1024\&. \fI*\fP 1024\&.));
719 \h'|11n'\*(+Kif\*(-K (vflag)
720 \h'|21n'vadvise(VA\*_ANOM);
721 \h'|11n'\*(+Kfor\*(-K (i = 0; i < niter; i++) \*(+K{\*(-K
722 \h'|21n'pn = random() % npages;
723 \h'|21n'\*(+Kif\*(-K (debug)
724 \h'|31n'printf("touch page %d\en", pn);
725 \h'|21n'pages[pagesize \fI*\fP pn] = 1;
735 \fI\h'\w' 'u-\w'/'u'/\fP\fI*\fP\c\c
738 \fI*\fP Random page access with
739 \fI*\fP a gaussian distribution\&.
741 \fI*\fP Allocate a large (zero fill on demand) address
742 \fI*\fP space and fault the pages in a random gaussian
744 \fI*\fP\fI\h'\w' 'u-\w'/'u'/\fP\c
748 \*(+Kfloat\*(-K\h'|11n'sqrt(), log(), rnd(), cos(), gauss();
749 \*(+Kchar\*(-K\h'|11n'\fI*\fPvalloc();
750 \*(+Kint\*(-K\h'|11n'rand();
754 \h'|11n'\*(+Kchar\*(-K \fI*\fPargv[];
756 \h'|11n'\*(+Kregister\*(-K \*(+Kint\*(-K pn, i, niter, delta;
757 \h'|11n'\*(+Kregister\*(-K \*(+Kchar\*(-K \fI*\fPpages;
758 \h'|11n'\*(+Kfloat\*(-K sd = 10\&.0;
759 \h'|11n'\*(+Kint\*(-K npages = 4096, pagesize, debug = 0;
760 \h'|11n'\*(+Kchar\*(-K \fI*\fPname;
762 \h'|11n'name = argv[0];
763 \h'|11n'argc\*-\*-, argv++;
765 \h'|11n'\*(+Kif\*(-K (argc < 1) \*(+K{\*(-K
768 "usage: %s [ \*-d ] [ \*-p #pages ] [ \*-s standard\*-deviation ] iterations\en", name);
771 \h'|11n'\*(+Kif\*(-K (strcmp(\fI*\fPargv, "\*-s") == 0) \*(+K{\*(-K
772 \h'|21n'argc\*-\*-, argv++;
773 \h'|21n'\*(+Kif\*(-K (argc < 1)
774 \h'|31n'\*(+Kgoto\*(-K usage;
775 \h'|21n'sscanf(\fI*\fPargv, "%f", &sd);
776 \h'|21n'\*(+Kif\*(-K (sd <= 0) \*(+K{\*(-K
777 \h'|31n'printf("%s: Bad standard deviation\&.\en", \fI*\fPargv);
780 \h'|21n'argc\*-\*-, argv++;
781 \h'|21n'\*(+Kgoto\*(-K again;
783 \h'|11n'\*(+Kif\*(-K (strcmp(\fI*\fPargv, "\*-p") == 0) \*(+K{\*(-K
784 \h'|21n'argc\*-\*-, argv++;
785 \h'|21n'\*(+Kif\*(-K (argc < 1)
786 \h'|31n'\*(+Kgoto\*(-K usage;
787 \h'|21n'npages = atoi(\fI*\fPargv);
788 \h'|21n'\*(+Kif\*(-K (npages <= 0) \*(+K{\*(-K
789 \h'|31n'printf("%s: Bad page count\&.\en", \fI*\fPargv);
792 \h'|21n'argc\*-\*-, argv++;
793 \h'|21n'\*(+Kgoto\*(-K again;
795 \h'|11n'\*(+Kif\*(-K (strcmp(\fI*\fPargv, "\*-d") == 0) \*(+K{\*(-K
796 \h'|21n'argc\*-\*-, argv++;
798 \h'|21n'\*(+Kgoto\*(-K again;
800 \h'|11n'niter = atoi(\fI*\fPargv);
801 \h'|11n'pagesize = getpagesize();
802 \h'|11n'pages = valloc(npages\fI*\fPpagesize);
803 \h'|11n'\*(+Kif\*(-K (pages == (\*(+Kchar\*(-K \fI*\fP)0) \*(+K{\*(-K
804 \h'|21n'printf("Can\'t allocate %d pages (%2\&.1f megabytes)\&.\en",
805 \h'|21n' npages, (npages\fI*\fPpagesize) \fI\h'\w' 'u-\w'/'u'/\fP (1024\&. \fI*\fP 1024\&.));
809 \h'|11n'\*(+Kfor\*(-K (i = 0; i < niter; i++) \*(+K{\*(-K
810 \h'|21n'delta = gauss(sd, 0\&.0);
811 \h'|21n'\*(+Kwhile\*(-K (pn + delta < 0 || pn + delta > npages)
812 \h'|31n'delta = gauss(sd, 0\&.0);
814 \h'|21n'\*(+Kif\*(-K (debug)
815 \h'|31n'printf("touch page %d\en", pn);
816 \h'|21n'\*(+Kelse\*(-K
817 \h'|31n'pages[pn \fI*\fP pagesize] = 1;
826 \h'|11n'\*(+Kfloat\*(-K sd, mean;
828 \h'|11n'\*(+Kregister\*(-K \*(+Kfloat\*(-K qa, qb;
830 \h'|11n'qa = sqrt(log(rnd()) \fI*\fP \*-2\&.0);
831 \h'|11n'qb = 3\&.14159 \fI*\fP rnd();
832 \h'|11n'\*(+Kreturn\*(-K (qa \fI*\fP cos(qb) \fI*\fP sd + mean);
841 \h'|11n'\*(+Kstatic\*(-K \*(+Kint\*(-K seed = 1;
842 \h'|11n'\*(+Kstatic\*(-K \*(+Kint\*(-K biggest = 0x7fffffff;
844 \h'|11n'\*(+Kreturn\*(-K ((\*(+Kfloat\*(-K)rand(seed) \fI\h'\w' 'u-\w'/'u'/\fP (\*(+Kfloat\*(-K)biggest);
860 'ds / \\h'\\w' 'u-\\w'/'u'/
861 'ds /* \\h'\\w' 'u-\\w'/'u'/*
870 'tl '\s14\f3\\*(=F\fP\s0'\\*(=H'\f3\s14\\*(=F\fP\s0'
873 \f2\s12\h'\\n(.lu-\w'\\*(=f'u'\\*(=f\fP\s0\h'|0u'
881 'ie o 'tl '\f2\\*(=M''Page % of \\*(=G\fP'
882 'el 'tl '\f2Page % of \\*(=G''\\*(=M\fP'
909 \f2\s14\h'\\n(.lu-\w'\\$1'u'\\$1\fP\s0\h'|0u'\c
910 .if r x .if \\nx .if d =F .tm \\$1 \\*(=F \\n%
914 .if r x .if \\nx .if d =F .tm \\$1 \\*(=F \\n%
923 .\" Copyright (c) 1985 The Regents of the University of California.
924 .\" All rights reserved.
926 .\" Redistribution and use in source and binary forms, with or without
927 .\" modification, are permitted provided that the following conditions
929 .\" 1. Redistributions of source code must retain the above copyright
930 .\" notice, this list of conditions and the following disclaimer.
931 .\" 2. Redistributions in binary form must reproduce the above copyright
932 .\" notice, this list of conditions and the following disclaimer in the
933 .\" documentation and/or other materials provided with the distribution.
934 .\" 3. All advertising materials mentioning features or use of this software
935 .\" must display the following acknowledgement:
936 .\" This product includes software developed by the University of
937 .\" California, Berkeley and its contributors.
938 .\" 4. Neither the name of the University nor the names of its contributors
939 .\" may be used to endorse or promote products derived from this software
940 .\" without specific prior written permission.
942 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
943 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
944 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
945 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
946 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
947 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
948 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
949 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
950 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
951 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
954 .\" @(#)a2.t 5.1 (Berkeley) 4/17/91
960 \*(+K#\*(-K! \fI\h'\w' 'u-\w'/'u'/\fPbin\fI\h'\w' 'u-\w'/'u'/\fPcsh \*-fx
961 \*(+K#\*(-K Script to run benchmark programs\&.
964 make clean; time make
966 time seqpage \*-p 7500 10
967 time seqpage \*-v \*-p 7500 10
968 time randpage \*-p 7500 30000
969 time randpage \*-v \*-p 7500 30000
970 time gausspage \*-p 7500 \*-s 1 30000
971 time gausspage \*-p 7500 \*-s 10 30000
972 time gausspage \*-p 7500 \*-s 30 30000
973 time gausspage \*-p 7500 \*-s 40 30000
974 time gausspage \*-p 7500 \*-s 50 30000
975 time gausspage \*-p 7500 \*-s 60 30000
976 time gausspage \*-p 7500 \*-s 80 30000
977 time gausspage \*-p 7500 \*-s 10000 30000
980 time pipeself 10000 512
981 time pipeself 10000 4
982 time udgself 10000 512
984 time pipediscard 10000 512
985 time pipediscard 10000 4
986 time udgdiscard 10000 512
987 time udgdiscard 10000 4
988 time pipeback 10000 512
989 time pipeback 10000 4
990 time udgback 10000 512
995 time forks 1000 102400
998 time vforks 1000 1024
999 time vforks 1000 102400
1002 time execs 1000 0 nulljob
1003 time execs 1000 1024 nulljob
1004 time execs 1000 102400 nulljob
1005 time vexecs 1000 0 nulljob
1006 time vexecs 1000 1024 nulljob
1007 time vexecs 1000 102400 nulljob
1009 time execs 1000 0 bigjob
1010 time execs 1000 1024 bigjob
1011 time execs 1000 102400 bigjob
1012 time vexecs 1000 0 bigjob
1013 time vexecs 1000 1024 bigjob
1014 time vexecs 1000 102400 bigjob
1015 \*(+K#\*(-K fill environment with ~1024 bytes
1016 setenv a 012345678901234567890123456789012345678901234567890123456780123456789
1017 setenv b 012345678901234567890123456789012345678901234567890123456780123456789
1018 setenv c 012345678901234567890123456789012345678901234567890123456780123456789
1019 setenv d 012345678901234567890123456789012345678901234567890123456780123456789
1020 setenv e 012345678901234567890123456789012345678901234567890123456780123456789
1021 setenv f 012345678901234567890123456789012345678901234567890123456780123456789
1022 setenv g 012345678901234567890123456789012345678901234567890123456780123456789
1023 setenv h 012345678901234567890123456789012345678901234567890123456780123456789
1024 setenv i 012345678901234567890123456789012345678901234567890123456780123456789
1025 setenv j 012345678901234567890123456789012345678901234567890123456780123456789
1026 setenv k 012345678901234567890123456789012345678901234567890123456780123456789
1027 setenv l 012345678901234567890123456789012345678901234567890123456780123456789
1028 setenv m 012345678901234567890123456789012345678901234567890123456780123456789
1029 setenv n 012345678901234567890123456789012345678901234567890123456780123456789
1030 setenv o 012345678901234567890123456789012345678901234567890123456780123456789
1032 time execs 1000 0 nulljob
1033 time execs 1000 1024 nulljob
1034 time execs 1000 102400 nulljob
1035 time execs 1000 0 bigjob
1036 time execs 1000 1024 bigjob
1037 time execs 1000 102400 bigjob