[net.sources] UNIX system benchmarks

dan@rna.UUCP (Dan Ts'o) (10/22/84)

: These are the UNIX systems benchmarks mentioned in net.unix
echo README
sed 's/^X//' > README << 'All work and no play makes Jack a dull boy'
X	To use these benchmarks, just type,
X
X		$ sh bench.sh
X	or
X		$ sh bench.sh >log 2>&1		#To save results
X
X	The Bourne shell is preferable because some UNIXes, e.g. 4.2BSD,
Xcan give more real-time resolution using /bin/time rather than the CSH's
Xinternal time command. However a CSH version, bench.csh, is also included.
X	Some possible difficulties that may be encountered include lack
Xof /tmp space and missing files. The shell scripts contain a parameter, $temp
Xwhich can be set to an alternative /tmp, e.g. /usr/tmp. The shell scripts
Xmake use of /usr/dict/words as a large source file (~200,000 bytes). Some
XUSG UNIXes may not have this file (their spell command now works differently).
XAn alternate 200,000 byte file may be substituted for the COPY benchmark.
XA substitute 200,000 byte file for GREP and SORT is more difficult, but
XI'm sure you can arrive at something (e.g. take a large document and transform
Xit to one word per line, uniq it, cat it several times to make 200,000).
X	If you don't have the MS nroff macros, use the MM macros.
X	Please note that SIEVE is identical to the benchmark published in BYTE,
XJan 1983 and used several more times in BYTE (e.g. Aug 1983). These articles
Xbenchmark many machines and results obtained with SIEVE should be directly
Xcomparable to that database. Subsequent user of the BYTE SIEVE have noted
Xthat it can be optimized, e.g. by using register variables. Of course it can
Xbe optimized, but that is not the point and to optimize it would destroy the
Xvalue of the results obtained on many machines to date.
X	The LOOP, CC LOOP benchmarks are identical to those used in recent
XUNIFORUM articles and should be directly compatible with those results. GETPID
Xshould be linearly compatible with benchmarks used by the UNIQUE newsletter -
Xthey use 10000 and 77777 getpid()'s, I use 100000 getpid()'s.
X	In addition, I have been experimenting with a terminal output benchmark,
XTERM, which is also included. Basically, TERM forks a process for each tty port
Xgiven and sprays characters to that port. One can then calculate the total tty
Xoutput capacity of a system. I haven't completed benchmarks with TERM and I want
Xto use it to determine any difference between DMF's in DMA and nonDMA mode.
X	Disclaimer: These are, of course, not the best benchmarks in the world,
Xthough I believe them to be capable of presenting a good first approximation
Xof a machine's UNIX system performance. A major criterion in choosing these
Xbenchmarks was the ability to perform them quickly and easily on many UNIX
Xsystems without typing in a lot of C code. A sample of two dozen machines
Xhas shown that the NROFF benchmark is a very effective single succinct predictor
Xof a system's mean performance for the entire benchmark "suite".
X	If you get any interesting results with these benchmarks, please send me
Xa copy ( cmcl2!rna!dan ). If you would like copies of the results from various
Xmachines as recently posted in two articles on USENET, send me mail about it.
X
X	To compute the VAX 11/780 normalization factor, divide the number
Xgiven below by the result obtained from the comparison machine for each
Xbenchmark.
X
X	780 time in seconds	Comparison time in seconds
XLOOP
X	2.5			user
XCC LOOP
X	3.4			real
XSIEVE
X	2.4			user
XCC SIEVE
X	4.4			real
XFLOAT
X	1.3			user
XGETPID
X	18.6			real (or user + system)
XGREP
X	4.1			real
XCOPY
X	2.0			real
XNROFF
X	4.1			real
XSORT
X	37.8			real
XNROFFMM (nroff -mm /dev/null)
X	14.3			real
X
X
X					Cheers,
X					Dan Ts'o
X					Dept. Neurobiology
X					Rockefeller Univ.
X					1230 York Ave.
X					NY, NY 10021
X					212-570-7671
X					...cmcl2!rna!dan
All work and no play makes Jack a dull boy
echo bench.sh
sed 's/^X//' > bench.sh << 'All work and no play makes Jack a dull boy'
X: This benchmark shell script is for use with the Bourne shell
Xtemp=/tmp
Xwho
Xecho No other users should be using the system.
Xecho Three CC LOOP
Xtime cc -O loop.c -o loop
Xtime cc -O loop.c -o loop
Xtime cc -O loop.c -o loop
Xecho Three LOOP
Xtime ./loop
Xtime ./loop
Xtime ./loop
Xecho Three CC SIEVE
Xtime cc -O sieve.c -o sieve
Xtime cc -O sieve.c -o sieve
Xtime cc -O sieve.c -o sieve
Xecho Three SIEVE
Xtime ./sieve
Xtime ./sieve
Xtime ./sieve
Xcc -O float.c -o float
Xecho Three FLOAT
Xtime ./float
Xtime ./float
Xtime ./float
Xcc -O getpid.c -o getpid
Xecho Three GETPID
Xtime ./getpid
Xtime ./getpid
Xtime ./getpid
Xecho Three NROFF
Xtime nroff -ms /dev/null
Xtime nroff -ms /dev/null
Xtime nroff -ms /dev/null
Xls -l /usr/lib/tmac.s /usr/lib/tmac/tmac.s
Xecho Ignore any tmac.s not found messages from ls.
Xcd /usr/dict
Xecho The next series of benchmarks requires the use of the file
Xecho /usr/dict/words or a similar large text file. /usr/dict/words
Xecho should be 200,000 bytes long, plus or minus a few percent.
Xls -l /usr/dict/words
Xecho Three GREP
Xtime grep zoom words
Xtime grep zoom words
Xtime grep zoom words
Xecho The next few benchmarks requires also that a sufficient of
Xecho temporary disk space. There should be at least 300,000 bytes
Xecho or so e.g. 1000 512 byte blocks available in $temp.
Xdf
Xsleep 5
Xecho Three COPY
Xtime cp words $temp/junk
Xrm -f $temp/junk
Xtime cp words $temp/junk
Xrm -f $temp/junk
Xtime cp words $temp/junk
Xrm -f $temp/junk
Xecho Three SORT
Xtime sort -r words > $temp/junk
Xrm -f $temp/junk
Xtime sort -r words > $temp/junk
Xrm -f $temp/junk
Xtime sort -r words > $temp/junk
Xrm -f $temp/junk
Xecho This concludes the benchmark.
All work and no play makes Jack a dull boy
echo bench.csh
sed 's/^X//' > bench.csh << 'All work and no play makes Jack a dull boy'
X#!/bin/csh
X# This benchmark shell script is for use with the C shell
Xset temp=/tmp
Xwho
Xecho No other users should be using the system.
Xecho Three CC LOOP
Xset time=1
Xcc -O loop.c -o loop
Xcc -O loop.c -o loop
Xcc -O loop.c -o loop
Xecho Three LOOP
X./loop
X./loop
X./loop
Xecho Three CC SIEVE
Xcc -O sieve.c -o sieve
Xcc -O sieve.c -o sieve
Xcc -O sieve.c -o sieve
Xecho Three SIEVE
X./sieve
X./sieve
X./sieve
Xecho CC FLOAT
Xcc -O float.c -o float
Xecho Three FLOAT
X./float
X./float
X./float
Xecho CC GETPID
Xcc -O getpid.c -o getpid
Xecho Three GETPID
X./getpid
X./getpid
X./getpid
Xecho Three NROFF
Xnroff -ms /dev/null
Xnroff -ms /dev/null
Xnroff -ms /dev/null
Xls -l /usr/lib/tmac.s /usr/lib/tmac/tmac.s
Xecho Ignore any tmac.s not found messages from ls.
Xcd /usr/dict
Xecho The next series of benchmarks requires the use of the file
Xecho /usr/dict/words or a similar large text file. /usr/dict/words
Xecho should be 200,000 bytes longs, plus or minus a few percent.
Xls -l /usr/dict/words
Xecho Three GREP
Xgrep zoom words
Xgrep zoom words
Xgrep zoom words
Xecho The next few benchmarks requires also that a sufficient of
Xecho temporary disk space. There should be at least 300,000 bytes
Xecho or so e.g. 1000 512 byte blocks available in $temp.
Xdf
Xsleep 5
Xecho Three COPY
Xcp words $temp/junk
Xrm -f $temp/junk
Xcp words $temp/junk
Xrm -f $temp/junk
Xcp words $temp/junk
Xrm -f $temp/junk
Xecho Three SORT
Xsort -r words > $temp/junk
Xrm -f $temp/junk
Xsort -r words > $temp/junk
Xrm -f $temp/junk
Xsort -r words > $temp/junk
Xrm -f $temp/junk
Xecho This concludes the benchmark.
All work and no play makes Jack a dull boy
echo float.c
sed 's/^X//' > float.c << 'All work and no play makes Jack a dull boy'
X#define	CONST1	3.1415926
X#define	CONST2	1.7839032
X#define	COUNT	10000
X
Xmain()
X{
X	double a, b, c;
X	int i;
X
X	a = CONST1;
X	b = CONST2;
X	for (i = 0; i < COUNT; ++i) {
X		c = a * b;
X		c = c / a;
X		c = a * b;
X		c = c / a;
X		c = a * b;
X		c = c / a;
X		c = a * b;
X		c = c / a;
X		c = a * b;
X		c = c / a;
X		c = a * b;
X		c = c / a;
X		c = a * b;
X		c = c / a;
X	}
X	printf("Done\n");
X}
All work and no play makes Jack a dull boy
echo getpid.c
sed 's/^X//' > getpid.c << 'All work and no play makes Jack a dull boy'
Xmain()
X{
X	long i;
X	for (i = 0; i < 100000; i++)
X		getpid();
X	printf("Done.\n");
X}
All work and no play makes Jack a dull boy
echo loop.c
sed 's/^X//' > loop.c << 'All work and no play makes Jack a dull boy'
Xmain()
X{
X	long i;
X	for (i = 0; i < 1000000; i++);
X	printf("Done.\n");
X}
All work and no play makes Jack a dull boy
echo sieve.c
sed 's/^X//' > sieve.c << 'All work and no play makes Jack a dull boy'
X#include <stdio.h>
X
X#define	NTIMES	10
X#define	SIZE	8190
X
X#define	FALSE	0
X#define	TRUE	1
X
Xchar flag[SIZE + 1];
X
Xmain()
X{
X	int i, j, k, count, prime;
X
X	printf("%d iterations:", NTIMES);
X
X	for (i = 1; i <= NTIMES; i++) {
X		count = 0;
X		for (j = 0; j <= SIZE; j++)
X			flag[j] = TRUE;
X		for (j = 0; j <= SIZE; j++) {
X			if (flag[j] == TRUE) {
X				prime = j + j + 3;
X				for (k = j + prime; k <= SIZE; k += prime)
X					flag[k] = FALSE;
X				count++;
X			}
X		}
X	}
X
X	printf("%d primes.\n", count);
X	exit(0);
X}
All work and no play makes Jack a dull boy
echo term.c
sed 's/^X//' > term.c << 'All work and no play makes Jack a dull boy'
X/*
X * Terminal output benchmark
X *	Daniel Ts'o, Rockefeller Univ.
X *
X *	output 1000*N characters to each given tty port
X *	Usage: term -## /dev/tty*
X *	N = ##, default 100
X * Best used with 9600 baud lines.
X */
X
X#include <stdio.h>
X#define	V7TTY				/* See tty_init() below */
X
X#define	NCHARLINE 50
X#define	NLINES 20
X#define	NCHAR	(NCHARLINE*NLINES)
X#define	NTIMES	100
Xchar buf[NCHAR];
X
Xint ntimes = NTIMES;
X
Xmain(c, v)
Xint c;
Xchar **v;
X{
X	register int i, j;
X	int status;
X
X	if (c > 1 && v[1][0] && (i = atoi(&v[1][1])) > 0) {
X		c--;
X		v++;
X		ntimes = i;
X	}
X	if (--c <= 0) {
X		fprintf(stderr, "Usage: term /dev/ttyXX ...\n");
X		exit(-1);
X	}
X	/* Fill character array */
X	for (i = j = 0; i < NCHAR; i++)
X		if (++j >= NCHARLINE-1) {
X			j = 0;
X			buf[i] = '\r';
X		}
X		else
X			buf[i] = 'X';
X	/* Open up each port and start */
X	while (--c >= 0) {
X		++v;
X		i = open(*v, 2);
X		if (i < 0)
X			perror(*v);
X		each(i);
X		close(i);
X	}
X	/* Wait for each child */
X	while (wait(&status) != -1);
X	exit(0);
X}
X
Xeach(fd)
Xint fd;
X{
X	register int i, j;
X
X	i = fork();
X	if (i != 0) {
X		if (i == -1)
X			perror("term");
X		return;
X	}
X	tty_init(fd);
X	tty_raw();
X	for (j = 0; j < NTIMES; j++)
X		write(fd, buf, NCHAR);
X	tty_cooked();
X	exit(0);
X}
X
X
X#ifdef	PWBTTY
X#include <sys/sgtty.h>
X#endif
X#ifdef	V7TTY
X#include <sgtty.h>
X#endif
X#ifdef	USGTTY
X#include <termio.h>
X#endif
X#ifdef	PWBTTY
Xstatic struct sgtty newstty, oldstty;	/* sgtty structures */
X#endif
X#ifdef	V7TTY
Xstatic struct sgttyb newstty, oldstty;	/* sgtty structures */
X#endif
X#ifdef	USGTTY
Xstatic struct termio newstty, oldstty;	/* termio structure */
X#endif
Xstatic int tty_file;
Xint ospeed;
X
Xtty_init(fd)
Xint fd;
X{
X	tty_file = fd;
X#ifdef	USGTTY
X	ioctl(tty_file, TCGETA, &oldstty);
X#else
X	fd = gtty (tty_file, &oldstty);
X	if (fd < 0)
X		return -1;
X#endif
X	newstty = oldstty;
X#ifdef	PWBTTY
X	newstty.sg_flag &= ~(CBREAK|CRMOD|ECHO);
X	newstty.sg_flag = RAW;
X	newstty.sg_ospd = B9600;
X	ospeed = oldstty.sg_ospd;
X#endif
X#ifdef	V7TTY
X	newstty.sg_flags &= ~(CBREAK|CRMOD|ECHO);
X	newstty.sg_flags = RAW;
X	newstty.sg_ospeed = B9600;
X	ospeed = oldstty.sg_ospeed;
X#endif
X#ifdef	USGTTY
X	newstty.c_lflag &= ~(ICANON|ECHO);
X	newstty.c_iflag &= ~ICRNL;
X	newstty.c_cc[VMIN] = 0;
X	newstty.c_cc[VTIME] = 0;
X	newstty.c_cflag &= ~CBAUD;
X	newstty.c_cflag |= B9600;
X	newstty.c_oflag = 0;
X	ospeed = oldstty.c_cflag&CBAUD;
X#endif
X	return 0;
X}
X
Xtty_raw () 
X{
X#ifdef	USGTTY
X	return ioctl(tty_file, TCSETAF, &newstty);
X#else
X	return stty (tty_file, &newstty); 
X#endif
X}
X
Xtty_cooked () 
X{
X#ifdef	USGTTY
X	return ioctl(tty_file, TCSETAF, &oldstty);
X#else
X	return stty (tty_file, &oldstty); 
X#endif
X}
All work and no play makes Jack a dull boy
exit