/* dskwtst.c -- write test wdsktst > filename result format: 20971520 bytes in 2.993907 seconds, 7.004733 MBps, 7.004733 MBps avg 20971520 bytes in 5.002443 seconds, 4.192256 MBps, 5.245273 MBps avg 20971520 bytes in 5.043581 seconds, 4.158061 MBps, 4.824762 MBps avg 20971520 bytes in 5.062376 seconds, 4.142624 MBps, 4.633999 MBps avg . . . . */ #include #include #include FILE *fileout; main(){ struct timeval tod; double oldtime, time, dtime=0.0; double totalc, ttotalc=0.0; int i, j, cc; char record[1024*1024]; fileout=stdout; for (j = 0; j < 1000; j++) { totalc=0.0; gettimeofday(&tod, 0); oldtime=(double)(tod.tv_sec)+((double)(tod.tv_usec)/1.e6); for (i = 0; i < 20; i++) { cc=fwrite((char *) record, sizeof(record),1,fileout); if(cc <= 0){exit(255);} totalc=totalc+(double)sizeof(record); } fflush(fileout); gettimeofday(&tod, 0); time=(double)(tod.tv_sec)+((double)(tod.tv_usec)/1.e6); ttotalc=ttotalc+totalc; dtime=dtime+(time-oldtime); fprintf(stderr,"%.0f bytes in %.6f seconds, %.6f MBps, %.6f MBps avg\n", totalc,time-oldtime,(totalc/(time-oldtime))/1000000., (ttotalc/dtime)/1000000.); /*fprintf(stderr,"%f\t%f\t%f\t%f\t%f\n",totalc,ttotalc,dtime,time,oldtime);*/ } }