gc vs explicit

Sean Kelly sean at f4.ca
Fri Dec 8 07:58:29 PST 2006


zz wrote:
> Dave wrote:
>> zz wrote:
>>
>>> Walter Bright wrote:
>>>
>>>> zz wrote:
>>>>
>>>>>  From my point of view these tests are not really nessesary on my 
>>>>> side since I still continue using D and I belive that someday the 
>>>>> memory stuff will be optimized.
>>>>
>>>>
>>>>
>>>> One thing that is happening is that the C++ code allocates memory, 
>>>> it never frees it. The same with the D code.
>>>
>>>
>>> Not until it's out of scope (in this case main).
>>>
>>
>> With that in mind, I wrapped your original code in a loop for 10 
>> iterations and decreased the inner loop to 100000.
>>
>> C++ (NedAlloc):
>> Total Element count: 1000000
>> 5.438000
>>
>> D:
>> Total Element count: 1000000
>> 1.360000
>>
> Cant' argue with that:
> In this case D is faster I get:
> C++ NedAlloc = 2.859
> D = 1.421
> 
> But if you leave the original count and put in the outer loop for 10, 
> D's performance becomes really bad.
> 
> c++ (NedMalloc) = 00:26.796
> D = 02:23.375

Try explicitly calling _gc.fullCollect() between iterations of the inner 
loop, and disabling the GC explicitly there.  Manipulation of the GC for 
performance-critical areas is an important and intentional feature.


Sean



More information about the Digitalmars-d mailing list