[Mono-list] offtopic, but cool

Cory Nelson phrosty@gmail.com
Wed, 12 May 2004 06:04:24 -0700


Yea I thought of that, but doing so made it take twice the time:

list<rect*> rl;
for(int i=3D0; i<1000000; i++) {
=09rect *r=3Dnew rect;
=09r->x=3Di;
=09r->y=3Di;
=09r->width=3Di;
=09r->height=3Di;

=09rl.push_back(r);
}


----- Original Message -----
From: Cesar Mello <cmello2@terra.com.br>
Date: Wed, 12 May 2004 09:41:24 -0300
Subject: Re: [Mono-list] offtopic, but cool
To: Cory Nelson <phrosty@gmail.com>
Cc: mono-list <mono-list@lists.ximian.com>


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.=20
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=E3o: 1.5.2
Proteja o seu e-mail Terra: http://www.emailprotegido.terra.com.br/