PC Review


Reply
Thread Tools Rate Thread

where is the bug here ? c++ faster than c# ?

 
 
pamela fluente
Guest
Posts: n/a
 
      29th Jan 2011
On this page:

http://www.elitetrader.com/vb/showth...&pagenumber=10

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 ?

 
Reply With Quote
 
 
 
 
pamela fluente
Guest
Posts: n/a
 
      29th Jan 2011
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 ...




 
Reply With Quote
 
pamela fluente
Guest
Posts: n/a
 
      29th Jan 2011
On 29 Gen, 13:56, Peter Duniho <NpOeStPe...@NnOwSlPiAnMk.com> wrote:
> On 1/29/11 8:23 PM, pamela fluente wrote:



> 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.


what would be a practical way to do that correctly ? (i mean, in
code)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why are SATA drives faster than PATA when parallel ports are faster than serial? Bob Computer Hardware 6 23rd Sep 2010 06:14 PM
Can faster CPU+larger/faster RAM significantly speed up recalulati =?Utf-8?B?am1rX2xp?= Microsoft Excel Misc 2 28th Sep 2005 10:24 AM
Goin' crazy faster and faster! eugene Anti-Virus 7 29th Nov 2004 07:46 PM
Re: which is faster (better) david epsom dot com dot au Microsoft Access Form Coding 0 9th Sep 2003 04:54 AM
which is faster (better) Drew Microsoft Access Form Coding 1 8th Sep 2003 11:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:08 AM.