[fpc-devel] Faster InitObject

Amir amir at aavani.net
Thu Feb 23 21:43:50 CET 2012

On 02/23/2012 11:37 AM, Hans-Peter Diettrich wrote:
> Amir schrieb:
>>>> Incl. Self. Called Function
>>>> 29.78 29.72 26M SYSTEM_FILLCHAR$formal$INT64$BYTE
>>>> 19.07 19.07 123M SYSTEM_MOVE$formal$formal$INT64
>>>> ....
>>> I suspect that the procedure initialization time is added to the first
>>> explicit statement. The initialization can include try-except/finally
>>> blocks, memory allocation (in constructors) or more.
>>> Please create another procedure or method, that uses FillChar not as the
>>> first statement, and test again.
>> I am not sure what you are asking. The callgrind outputs the call tree
>> and other information....
> It's not the first time that somebody complains about slow FillChar. I
> simply doubt that it really as slow as reported. In above table I'd
> expect that SysGetMem should be slower than FillChar.
> DoDi
The performance of FillChar is not my problem, The main issue in my case 
is that my class has a big array defined inside it. I developed my code 
such that this array does not need to be initialized with zero initially 
(I have not assumed anything about the content of this array).
But the InitInstance function, initialize the array with zero.

I can see a simple solution to resolve my problem. I can change the 
array, in my class, to a dynamic array or pointer or ...
But what if I had, let's say, many variables inside my class? Or a big 
data structure?


More information about the fpc-devel mailing list