in reply to Script to create huge sample files

3 MB is not huge. In the context of terrabyte drives and multiple GB of physical memory it is in fact trivial! Assembling your output image in memory by simply concatenating copies of the input file on to the end of a string, then printing the resulting string to your output file is likely to be fast and easy to code. length then can be used to calculate how many copies you need and how big your output image is currently.

However, depending on the contents of the file and how it will be processed, assembling a test file in this fashon seems highly dubious to me! You would probably be better to figure out a way of generating realistic data that will provide a though test set for your benchmarking tests. If the code being tested behaves differently for the first instance of a record than for subsequent occurrences, or if different record data is more expensive (in terms of processor time) than other data then your multiple copy data file may introduce nasty biases in the benchmark results.


True laziness is hard work