I wrote a small (GUI) program with Delphi which tests the performance writing to a file on a drive. It creates a file and then writes "random" numbers to it. I have the following array:
var CopyArray : array[1..25000] of LongInt;which I fill with numbers in a loop and then write it to disk with BlockWrite:
for i := low(CopyArray) to high(CopyArray) do
CopyArray[i] := random(10000);
BlockWrite(Datei,CopyArray,sizeof(CopyArray),geschrieben);(This loop is put in another loop to get different file sizes (multiples of sizeof(CopyArray))). Time is measured to calculate the transfer rate. This works on Delphi and I also can run it under Lazarus (with some minor changes around the UI).
But there is a significant performance difference between the Delphi version and the Lazarus version: The Delphi version is always about 11% faster than the Lazarus version (independent from the transfer rate). I found out that if I change the assignment to CopyArray using a constant as in
for i := low(CopyArray) to high(CopyArray) do
CopyArray[i] := 77777;then this difference disappears (so this speeds up the file writing by 10%)! If I do the same in the Delphi version there are no changes in the transfer rates.
I don't know why that happens because this slowdown appears on all tranfer rates (30 MB/s or 10 MB/s). If the random function eats up performance (more than the same in Delphi) then this effect should be less or invisible on slow disk transfer rates because the program overhead disappears in relation to total times. But that does not happen.
Any ideas?
