/**************************************************************************** * * trandbig.cpp 2007.08.04 Smythies * Add the define for _FILE_OFFSET_BITS. For the Linux compile, * this will force the use of the LFS (Large File System) library * instead of the 2 gigabyte limited default. * For the Windows compile, it shouldn't make any difference. * * trandbig.cpp 2007.08.03 Smythies * Make a large file of random bytes. Then the file should not * compress very well at all. Used for checking network and disk * rates. * See also trandmsr.cpp, trandm2r.cpp, trandt1g.cpp * ****************************************************************************/ #define _FILE_OFFSET_BITS 64 #include #include #define GIGS 8 #define WRITE_SIZE 1048576 char pattern[WRITE_SIZE]; /* */ long i, j, k; main(){ int err; FILE *out; if((out = fopen("big", "wb")) == NULL){ printf("Cannot open output file\n"); return(1); } /* endif */ srand(79); for(j = 0; j < GIGS; j++){ printf("\nCompleted 1 gig loops: %4ld\n", j); for(i = 0; i < 1024; i++){ /* a gigabyte at a time */ printf("."); for(k = 0; k < WRITE_SIZE; k++){ pattern[k] = (char)(255&(rand())); } /* endfor */ err = fwrite(&pattern,1,WRITE_SIZE,out); if(err != WRITE_SIZE){ printf("problem writing output. Bytes = %d\n",err); fclose(out); return(1); } /* endif */ } /* endfor */ } /* endfor */ fclose(out); return(0); } /* endprogram */