/* * * "I/O Stone" Benchmark Program * * Written by: Arvin Park (park@midas.ucdavis.edu) and * Jeff Becker (becker@iris.ucdavis.edu) * Division of Computer Science * University of California, Davis * Davis CA 95616 * (916) 752-5183 * * Version C/II * Date: 06/27/90 * * Defines: If your version of "C" does not include an ftime() * function or the C library time.h, define NOTIME. * Use a stopwatch to measure elapsed wall time. * Divide 2,000,000 by the elapsed time to get * the correct number of iostones/second. * * To compile: cc -O io.c -o io * * Note: [1] This program should be run without other processes * competing for system resources. Run it in the dead of * night if you have to. * * [2] This program uses 5 megabytes of disk space. Make * sure that at least this much space is available on * your file system before you run the program. * * Results: If you get results from a new (machine/operating * system/disk controller and drive) combination, please * send them to becker@iris.ucdavis.edu. Please include * complete information on the machine type, operating * system, version, disk controller, and disk drives. * Also make a note of any system modifications that * have been performed. */ #include #define BFLUSH_FILE_SIZE (512L*1024L) /*size of files used to flush buffers*/ #define NBFLUSH_FILES 8 /*number of files used to flush buffers*/ #define NBLOCKSIZES 9 /*number of different block sizes*/ #define SEED 34710373L /*random number generator seed*/ #define CONST 500000L /*iostone normalization constant*/ #define ITER 4 /*number of iterations of the code*/ #define BUFFERSIZE (16L*1024L) /*size of temporary buffer*/ /* define only one of the next three defines */ /*#define NOTIME /* Define if no time function in library */ #define TIME /* Use UNIX time function */ /*#define NON_UNIX_TIME /* Use if a non-unix system */ #define NSETS 4 /*number of sets of files*/ #define SET_SIZE 99 /*number of files in each set*/ #define FNAMELEN 20 /*maximum file name length*/ char *malloc(); char tmp[FNAMELEN]; /*a temporary string*/ char *files[NSETS][SET_SIZE]; /*array of file names*/ char *buf_flush_files[NBFLUSH_FILES]; /*array of names of files to flush*/ /*system buffers*/ char buffer[BUFFERSIZE]; /*a temporary buffer*/ long int nbytes; /*number of bytes transfered*/ int fd; /*file descriptor*/ int i,j,k; /*counter variables*/ long bsize[NBLOCKSIZES]; /*array for different block sizes*/ int bfreq[NBLOCKSIZES]; /*number of accesses for each block*/ #ifdef TIME #include #include struct timeb before; struct timeb after; int sec; int msec; #endif #ifdef NON_UNIX_TIME long starttime; long totaltime; #endif main() { init(); /*start timing*/ #ifdef NOTIME printf("start timing\n"); #endif #ifdef TIME ftime(&before); #endif #ifdef NON_UNIX_TIME starttime = time(0); #endif for(k=0; k0;j--) { k=my_rand(j); strcpy(tmp,files[i][j-1]); strcpy(files[i][j-1],files[i][k]); strcpy(files[i][k],tmp); } } } my_rand(max) int max; { #ifdef NON_UNIX_TIME return rand()%max; #else return random()%max; #endif } initfile(fname, fsize) char *fname; long fsize; { /*create a temporary file*/ FILE *fs; int block, num_blocks; if((fs=fopen(fname,"w"))==NULL){ printf("init: Cannot create temporary file\n"); exit(1); } rewind(fs); /*write initial portion of file*/ if (fsize > BUFFERSIZE) { num_blocks=fsize/BUFFERSIZE; for(block=0;block= BUFFERSIZE) { num_xfer = bsize[fsize_index]/BUFFERSIZE; xfer_amt = BUFFERSIZE;} else { num_xfer = 1; xfer_amt = bsize[fsize_index];} rnum = my_rand(3); if (rnum < 2) { /*read:write = 2:1*/ lseek(fd,0L,0); for (xfer=0; xfer