Skybuck Flying
2004-12-05 13:16:18 UTC
Hi,
I might have a little speed "problem" with using dynamic arrays and
SetLength.
The SetLength routine calls FillChar to clear the contents of the dynamic
array.
In my case it is not necessary to clear the contents of the dynamic array
since it will be replaced anyway.
My concern is speed.
I need to allocate many dynamic arrays and then later "truncate" them.
This needs to happen as fast as possible.
There is a huge performance difference between getmem/freemem and setlength.
For example while benchmarking both. My PIII 450 mhz was able to
getmem/freemem 66000 bytes 30000 times per second.
While it was only able to setlength( 66000), setlength( 400) about 1800
times.
To make it completely fair I also tested:
SetLength( 66000 ) and
Buffer := nil;
Same result (only 1800 times)
Could borland please make a version of SetLength where the contents are not
cleared ?
For example SetLengthFast or so ?
or
SetLengthNoClear ;)
I might be able to make my own SetLengthFast version but then I would need
to know how to call it:
{ PROCEDURE _DynArraySetLength(var a: dynarray; typeInfo:
PDynArrayTypeInfo; dimCnt: Longint; lengthVec: ^Longint) }
_DynArraySetLength( MyArray, ?, ?, ? )
Bye,
Skybuck.
I might have a little speed "problem" with using dynamic arrays and
SetLength.
The SetLength routine calls FillChar to clear the contents of the dynamic
array.
In my case it is not necessary to clear the contents of the dynamic array
since it will be replaced anyway.
My concern is speed.
I need to allocate many dynamic arrays and then later "truncate" them.
This needs to happen as fast as possible.
There is a huge performance difference between getmem/freemem and setlength.
For example while benchmarking both. My PIII 450 mhz was able to
getmem/freemem 66000 bytes 30000 times per second.
While it was only able to setlength( 66000), setlength( 400) about 1800
times.
To make it completely fair I also tested:
SetLength( 66000 ) and
Buffer := nil;
Same result (only 1800 times)
Could borland please make a version of SetLength where the contents are not
cleared ?
For example SetLengthFast or so ?
or
SetLengthNoClear ;)
I might be able to make my own SetLengthFast version but then I would need
to know how to call it:
{ PROCEDURE _DynArraySetLength(var a: dynarray; typeInfo:
PDynArrayTypeInfo; dimCnt: Longint; lengthVec: ^Longint) }
_DynArraySetLength( MyArray, ?, ?, ? )
Bye,
Skybuck.