I badly need a random file generator that generates a truly random, non-compressible dummy files.
I ended up with this delphi code. It works, but it's painfully sloooow
var
Buf : Integer;
TheFile : TFileStream;
begin
TheFile := TFileStream.Create(FileName, fmCreate OR fmOpenReadWrite);
with TheFile do
begin
for i := 0 to FileSize do // Iterate
begin
Buf := Random(999999) * i;
WriteBuffer(Buf, SizeOf(Buf));
end; // for
end; // with
end,
My question is: Is there a fast random file generator that I can use? Both Delphi code and/or commandline tools are acceptable as long as:
EDIT For those interested, I applied the advice I received here and made this function, it's fast enough & 7zip has hard time compressing the generated data.
Use a 4096-byte page-size, or multiple page-size, buffer. Writing one integer at a time will be slow.
You can use my generate_random_file.py script (Python 3) that I used to generate test data in a project of mine.
os.urandom()
to generate the random data in chunks of 256 KiB instead of generating and writing each byte separately.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With