MIT Technology Review: An Interview With Bjarne Stroustrup

zz zz at zz.com
Wed Dec 6 16:44:18 PST 2006


Frits van Bommel wrote:
> zz wrote:
> 
>>         cpp_element* element = new cpp_element();
>>
>>         element->CreationDate = cd1 + "cd1";
>>         element->Creator      = cd2 + "cd2";
>>         element->Label        = cd3 + "cd3";
> 
> <snip>
> 
>>         d_element element = new d_element();
>>         element.CreationDate = cd1 ~= "cd1";
>>         element.Creator      = cd2 ~= "cd2";
>>         element.Label        = cd3 ~= "cd3";
> 
> 
> I don't think those lines are really equivalent. Hint: write the last 
> element in the list to output, in both versions. You might notice a 
> difference :).

Ouch. That was really silly of me (Didn't notice it).
It should have been element.CreationDate = cd ~ "cd1" and yes it would 
make a difference.

What I had yesterday was using cd1.dup, didn't notice the silly mistake 
when making the change.

After fixing this problem here are my results on a different machine.

 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.

Zz

-------------------------------------------------------
VS2003
Element count: 1000000

ContextSwitches - 24787
First level fills = 0
Second level fills = 0

ETime(   0:00:05.328 ) UTime(   0:00:05.046 ) KTime(   0:00:00.187 )
ITime(   0:00:04.828 )

-------------------------------------------------------
VS2003 with nedmalloc
Element count: 1000000

ContextSwitches - 8854
First level fills = 0
Second level fills = 0

ETime(   0:00:02.390 ) UTime(   0:00:02.218 ) KTime(   0:00:00.078 )
ITime(   0:00:02.015 )

-------------------------------------------------------
DMC
Element count: 1000000

ContextSwitches - 35008
First level fills = 0
Second level fills = 0

ETime(   0:00:07.312 ) UTime(   0:00:07.000 ) KTime(   0:00:00.031 )
ITime(   0:00:06.656 )

D change:
	for(int i = 0; i < 1000000; i++)
	{
		d_element element = new d_element();
		element.CreationDate = cd1 ~ "cd1";
		element.Creator      = cd2 ~ "cd2";
		element.Label        = cd3 ~ "cd3";
		root.elements ~= element;
	}








More information about the Digitalmars-d mailing list