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

In reply to Re: Script to create huge sample files by GrandFather
in thread Script to create huge sample files by paragkalra

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.