Re: Poor array performance
- From: "John Mark Howell" <jmarkhowell@xxxxxxxxxxx>
- Date: Thu, 9 Feb 2006 11:58:22 -0600
Ouch. I should have looked closer at the code and tested the results before
posting. That would have avoided some confusion. Thanks for setting me
straight on what was actually happening. After I fixed my code here, you
are correct, I'm getting equivalent speed to the C# code.
"Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx> wrote in message
news:erF83LZLGHA.3960@xxxxxxxxxxxxxxxxxxxxxxx
No I mean that the C++ figures are wrong because of "broken" optimization.complete,
If I run the code (managed C++) you posted it takes 0.210 secs. to
impressive, but I don't trust it.make
Now if I watch the memory consumption when running (1000 iterations to
it possible to measure), the "private bytes" counter stays at ~9 Mb andthe
working-set at ~6.5 Mb, wich is the minimum for a ".NET" process, thistwo
smells like agressive optimization. Why?, well the program should create
arrays of doubles (well, the optimizer could optimize away the firstarray),
each of them - 8784*1000*sizeof(double) = 70.272.000 bytes. That meansthat
the final private bytes count should reach at least 70.272.000 (orloop:
140.544.000 bytes).
So it's clear that NO arrays are created, that would mean both array
creation are optimized away (which is possible because they aren't used
outside the loop, right?
So I decided to look at the results, by including this code after the
at
for (Hourly_Index = 0; Hourly_Index < 1; Hourly_Index++)
{
for (Iteration_Index = 0;Iteration_Index < 1000 ; Iteration_Index++ )
{
Console::WriteLine("{0}", Convert::ToString(vombase[Iteration_Index,
Hourly_Index]));
}
}
See, I'm only interested at the first 1000 elements, and he! they are all
0, thus wrong! The I watched the last elements values, they are all atI
998001, which is 999^2 or the largest value calculated in the loop. Finaly
checked all the 'values' and guess, there are only 0 (the first 1.000.000)the
and 998001 (the remaining), but still no array's, the memory consumption
remain the same.
So, this is what I call "broken optimization", the results are wrong, so
benchmarh time is bogus.correct,
Note that I did the same with the C# code, and here the results are
memory consumption is > 140Mb and the benchmark time is correct (5.2 Secs.
on my box).
Actually I didn't look into the generated code, I will do is I find some
spare time.
Willy.
.
- Follow-Ups:
- Re: Poor array performance
- From: Willy Denoyette [MVP]
- Re: Poor array performance
- References:
- Poor array performance
- From: John Mark Howell
- Re: Poor array performance
- From: Willy Denoyette [MVP]
- Re: Poor array performance
- From: John Mark Howell
- Re: Poor array performance
- From: Willy Denoyette [MVP]
- Poor array performance
- Prev by Date: Re: Does project load DLL multiple times?
- Next by Date: Re: Meaning of VS2K5 icons?
- Previous by thread: Re: Poor array performance
- Next by thread: Re: Poor array performance
- Index(es):
Relevant Pages
|