On 29 Gen, 13:56, Peter Duniho <NpOeStPe...@NnOwSlPiAnMk.com> wrote:
> On 1/29/11 8:23 PM, pamela fluente wrote:
>
> > On this page:
>
> >http://www.elitetrader.com/vb/showth...d=213861&perpa...
>
> > there are 2 simple tests *(source code), just a couple of loops
>
> > the test seems to say that c++ is much faster than c#. Is this code
> > flawed or what ? I don't believe that is true ... what's the problem ?
>
> I didn't spend much time looking at the code. *These kinds of tests do
> very little to show what real-world differences may or may not exist
> between languages. *The real question isn't whether C++ is or is not
> significantly faster than C#. *It's whether the C# program is able to
> meet your specific performance requirements. *I've yet to run into a
> real-world situation where C# genuinely could not be made to run as well
> as C++ code for the intended purpose.
>
> That said, one thing stands out, in that the C# code is using a much
> less accurate timer mechanism than the C++ code. *It's entirely possible
> that a significant portion of the apparent difference is simply due to
> measurement error.
>
> The fact that the C++ code shows times evenly distributed between 20 and
> 23 ms, while the C# code shows basically just two different timing
> results (140/141 and 156 ms) strongly suggests at least _some_ sort of
> measurement error is going on. *Real programs don't quantize timings
> like that, but imprecise timers do.
>
> The other thing that stands out with respect to the post itself is that
> the C# test program does no "warm-up" execution at all (to ensure the
> code has been JITted and the various CPU caches have stabilized before
> timing), and yet the first iteration is within the tests own margin of
> error relative to the subsequent eight iterations.
>
> I've also never seen a C++ compiler that would inline a function as
> large as the one in that test, nor would inlining have any noticeable
> effect on the overall performance of the program (none of real time
> spent in the code involves any function calls at all). *The idea that
> the poster needed to "downgrade the optimizations" is suspicious to me.
>
> Finally, without a complete description of the test conditions,
> including whether a debugger was attached, and what compiler switches
> were used to compile the code, it's impossible to confirm that the
> person was comparing apples to apples.
>
> I won't go so far to say that the person is just making his test results
> up. *But if I actually cared about whether the test was valid or not
> (and frankly, I don't…as I said, even if the test is completely
> accurate, it doesn't tell us anything useful), I would make damn sure I
> verified the test myself, using a proper timing object (i.e. Stopwatch),
> and doing a warm-up run (or just ignoring the first iteration). *I
> definitely wouldn't take the word of a post you found on the Internet.
>
> Pete
yep i fully agree that such a difference is not believable.
There must be something wrong. I just wanted to hear your opinions.
(sorry, not seeing it, i repeated the post)
I have seen an answer saying that i should not be surprised
because c# is "interpreted"
Well i still am: differences, if any can't be that large ...