I'm using this code to save/write a plain-text file:
var
i: int64;
myFile : TextFile;
bytes: int64;
begin
AssignFile(myFile, FileName);
ReWrite(myFile);
CloseFile(myFile);
Append(myFile);
bytes:=1073741824; // 1GB
i:=1;
while (i<=bytes) do
begin
write(myFile, 'a');
inc(i);
end;
CloseFile(myFile);
end;
It perfectly creates the test file. However it takes a lot of time. It may be acceptable for HDD drives but it is very slow for NVMe SSD drives.
How can I make this code faster?