yeap you're right! I didn't notice the struct was small. I'd like to see the struct you used in the C++ sample if possible (just 4 ints?)
I'll do the same benchmark later when I get home, and try with different compilers and allocators. Pretty interesting!
Best regards, Mello
Cory Nelson wrote:
Yea I thought of that, but doing so made it take twice the time:
list<rect*> rl; for(int i=0; i<1000000; i++) { rect *r=new rect; r->x=i; r->y=i; r->width=i; r->height=i;
rl.push_back(r); }
----- Original Message ----- From: Cesar Mello <[EMAIL PROTECTED]> Date: Wed, 12 May 2004 09:41:24 -0300 Subject: Re: [Mono-list] offtopic, but cool To: Cory Nelson <[EMAIL PROTECTED]> Cc: mono-list <[EMAIL PROTECTED]>
Hi Cory,
In the C++ sample, you are passing the rect by value, so you are saving a copy in the list. In C# a reference to the object is used, so there is no copy-construction overhead.
You can change the list<rect> to a list<rect*>, but this way you have to manage the memory by yourlself.
[] Mello
Cory Nelson wrote: Just got done installing the VS.NET 2005 preview and did a small test.
I compared an ArrayList of Rectangles to a List<Rectangle>, and timed
inserting 1mil rects into each. I also wrote an equivalent c++ app. Got some interesting results:
ArrayList: 265ms List<Rectangle>: 62ms list<rect>: 141ms
So it seems with generics .NET is finally faster than c++ (at least, in this case).
Esta mensagem foi verificada pelo E-mail Protegido Terra. Scan engine: VirusScan / Atualizado em 10/05/2004 / Versão: 1.5.2 Proteja o seu e-mail Terra: http://www.emailprotegido.terra.com.br/
Esta mensagem foi verificada pelo E-mail Protegido Terra. Scan engine: VirusScan / Atualizado em 10/05/2004 / Versão: 1.5.2 Proteja o seu e-mail Terra: http://www.emailprotegido.terra.com.br/
_______________________________________________ Mono-list maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-list