Xref: utzoo comp.protocols.nfs:442 comp.sys.mips:172
Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!watmath!gamiddleton
From: gamiddleton@watmath.waterloo.edu (Guy Middleton)
Newsgroups: comp.protocols.nfs,comp.sys.mips
Subject: Re: weird NFS speeds
Message-ID: <29735@watmath.waterloo.edu>
Date: 3 Oct 89 15:44:43 GMT
References: <29591@watmath.waterloo.edu>
Reply-To: gamiddleton@watmath.waterloo.edu (Guy Middleton)
Organization: University of Waterloo [MFCF/ICR]
Lines: 97

In article <29591@watmath.waterloo.edu> gamiddleton@watmath.waterloo.edu (Guy Middleton) writes:
> I have been testing NFS performance on some workstations, using a program to
> write a 20-megabyte file with different-sized buffers.

A couple of people have suggested that I post the program I used.  It's no big
deal.  There is no timing code here, I used csh's "time" function to get
elapsed and CPU times:

#include 
/*
 * some BSD-like systems don't define "BSD" in the preprocessor
 * you may have to do it by hand
 */
#ifdef BSD
#include 
#else
#include 
#endif

#define	BLOCK		1024

#define	BUFBLOCKS	8		/* # of BLOCKs per read/write */
#define	FILESIZE	(1024 * 20)	/* size of file in BLOCKs */

#define	WRITE		(O_CREAT|O_RDWR)
#define	READ		O_RDONLY

#define	LINELEN		128

char	filename[] = "xxx";

/*
 * syntax:
	io ["read" | "write"] [blocksize]
 * default is read 8K blocks
 */

main( argc, argv )
	char **argv;
{
	extern char *calloc();
	extern int read(), write();

	int i, ff, iterations;
	unsigned memsize;
	char *mp;

	unsigned bufblocks = BUFBLOCKS;
	int mode = READ;
	int (*func)() = read;


	for (i = 1; i < argc; i++) {
		if (strcmp( argv[i], "write" ) == 0) {
			mode = WRITE;
			continue;
		}
		if (strcmp( argv[i], "read" ) == 0) {
			mode = READ;
			continue;
		}
		bufblocks = atoi( argv[i] );
	}
	
	memsize = bufblocks * BLOCK;

	if (mode == WRITE) {
		func = write;
		printf( "writing" );
	}
	else
		printf( "reading" );

	printf( " with buffer size %d\n", memsize );

	if ((mp = calloc(memsize, (unsigned) 1)) == (char *) NULL) {
		perror("calloc");
		exit(1);
	}

	if ((ff = open(filename, mode, 0666)) < 0) {
		char errmsg[LINELEN];
		sprintf( errmsg, "open %s", filename );
		perror( errmsg );
		exit(1);
	}

	iterations = FILESIZE / bufblocks;

	for (i=0; i