On Sunday 28 January 2001 10:09 pm, Frank Heckenbach wrote:
procedure FillChar (var Dest; Count: SizeType; Val: Char); or procedure FillChar (var Dest; Count: SizeType; Val: Byte);
Thanks (both of you). I tried that on an array[1..1000,1..1000] of integer, and the difference in time taken between
for i := 1 to 1000 do for j := 1 to 1000 do x[i,j] := 0;
and
fillchar(x, sizeof(x), 0)
was very small (the first took 18637 usec and the second took 17478 usec). But replacing sizeof(x) with 1000000 made it much faster (5348 usec).
So it seems that if you have to use sizeof, it's not really worth using fillchar. I'm a bit surprised by how expensive sizeof appears to be.
Do you have any feeling for how efficient the code produced by gpc is? Is it something you're looking to improve, or are you happy with it? I find that code compiled with gpc runs at about 75% of the speed of equivalent code compiled with gcc (using -O3 -march=i686 in both cases). Is this just a fact of life of using Pascal?