* Old Wolf:
> On Mar 3, 11:24 pm, "Alf P. Steinbach" <a...@start.no> wrote:
>> Bas wrote:
>>> Test *ar[30000000];
>>> for(long int j = 0; j< 30000000; j++)
>>> ar[j] = new Test;
>> std::vector<Test> v( 30000000 );
>
> The thing being benchmarked was 30000000 small allocations.
> Your suggested code performs 1 large allocation.
>
> (I'm sure you know this; but just clearing it up for other readers who
> may not).
Yes. The point is that for a an ordinary C# 'class' object (reference
semantics) you have to do those 30M separate allocations to have the 30M
objects you need, whatever the reason could be for that need, whereas in
C++ you can do just one big allocation. So as a /language/ comparision
this one decidedly favors C++, some millions times faster than C#.
I think if the comparision is meaningful in any way, then that way must
be it.
Cheers,
- Alf
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
|