Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. C# vs. C++ performance [modified] (Contest)

C# vs. C++ performance [modified] (Contest)

Scheduled Pinned Locked Moved The Lounge
csharpc++htmlcss
60 Posts 18 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E El Corazon

    Jeremy Falcon wrote:

    If I'm using MSVC, do you think it's really worth it to switch over to Intel's compiler? And, does it integrate into VS? Just curious to know, as I've never used it, but I've heard positive stories about it.

    It integrates pretty close to seamlessly into the VS environment. As for efficiency, that is a tough one. The Intel compiler does a better job at optimizing unoptimized code. If you are already an expert at writing optimized algorithms the only benefit would be seamless integration to VTune to let you hand-optimize your algorithms. We've had anywhere from 1% to 20% improvements.

    _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

    J Offline
    J Offline
    Jeremy Falcon
    wrote on last edited by
    #51

    Jeffry J. Brickley wrote:

    The Intel compiler does a better job at optimizing unoptimized code.

    Well, I'd like to think my code is optimized, but that very well may not be the case. :laugh: Thanks for the info.

    Jeremy Falcon

    1 Reply Last reply
    0
    • S Super Lloyd

      Hey, I did optimize both! didn't you see the -O3 ?! Well the result are... well.... I didn't know gcc was that bad!.... :omg: That make me rethink about life! :laugh:

      J Offline
      J Offline
      Jorgen Sigvardsson
      wrote on last edited by
      #52

      Did you try -O2 for optimization? -O2 generally optimizes better than -O3. At least it did so back in the days. :)

      -- In Hypno-Vision

      S 1 Reply Last reply
      0
      • S Super Lloyd

        On another thread some posted this link: http://www.csharphelp.com/archives2/archive458.html[^] Now I was very suprised by this bad C# result, it's not at all what I experience! So I decided to test my self! I have .NET 2 and gcc 3.4.4 I compiled like this: CPP> gcc -O3 -o sieve2.exe sieve.cpp -lstdc++ C#> csc /o+ /nologo /out:sieve.exe Sieve.cs I got: C# 10000 Milliseconds = 1156 C++ 10000 Milliseconds = 1313 Haheum..... what else can I say? -- modified at 11:18 Tuesday 1st August, 2006 I propose a Contest. Post a small C++ performance test program here (less than 200 readable lines). I'll try to beat it with a C# version!

        J Offline
        J Offline
        Joe Woodbury
        wrote on last edited by
        #53

        A few months ago, I realized that time critical C# algorithm I was working on was similar to some C++ code I had worked on previously (no big surprise since I wrote both.) My curiosity got the better of me and I spent several hours setting up performance comparisons. One thing led to another and I ended up doing even more performance comparisons. I couldn't resist throwing the code into managed C++ and trying that. On average, FOR THESE TESTS, I found that the managed C++ code ran twice as fast as the C# code and the native C++ code ran twice as fast as the managed C++ code. There was one exception; I could fill a list box with thousands of items faster in C# than in native Win32 (The performance still stunk; I needed to fully virtualize both, but I'm not on that project any more so I don't care.)

        Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

        1 Reply Last reply
        0
        • N Nemanja Trifunovic

          Super Lloyd wrote:

          and I though a new at each iteration was overkill

          Of course it is an overkill, but it is a benchmark, isn't it?

          Programming Blog utf8-cpp

          S Offline
          S Offline
          Super Lloyd
          wrote on last edited by
          #54

          it is not equal! in C++ it is just one instruction to move the stack pointer and not so in C#...

          N 1 Reply Last reply
          0
          • M Marc Clifton

            Uh, frankly, 95% of the time, I don't care. 95% of the time, the programmer writes such crappy code, performance is the least of my worries. Marc

            XPressTier

            Some people believe what the bible says. Literally. At least [with Wikipedia] you have the chance to correct the wiki -- Jörgen Sigvardsson
            People are just notoriously impossible. --DavidCrow
            There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer

            S Offline
            S Offline
            Super Lloyd
            wrote on last edited by
            #55

            I have no worry, I was already sold to C#. But it's just that all my test showed that C# is just as good as C++ speedwise, so I wanted to dispel the misperception! Unfortunately I was wrong and I also learnt that GCC is a slow compiler as well. It's all good mate! ;P

            1 Reply Last reply
            0
            • J Jorgen Sigvardsson

              Did you try -O2 for optimization? -O2 generally optimizes better than -O3. At least it did so back in the days. :)

              -- In Hypno-Vision

              S Offline
              S Offline
              Super Lloyd
              wrote on last edited by
              #56

              Okay, let's try! It's a little bit better, but still slower than C#

              J 1 Reply Last reply
              0
              • S Super Lloyd

                Okay, let's try! It's a little bit better, but still slower than C#

                J Offline
                J Offline
                Jorgen Sigvardsson
                wrote on last edited by
                #57

                Did you try the other optimization features that come with gcc? There's a bunch of -f-XXX flags that do stuff. But, don't get your hopes up though. GCC isn't the best compiler out there, at least not for C++. It would be interesting to compare a hand optimized version in assembler with C#. Care to write one? ;)

                -- Based on a True Story

                S 1 Reply Last reply
                0
                • J Jorgen Sigvardsson

                  Did you try the other optimization features that come with gcc? There's a bunch of -f-XXX flags that do stuff. But, don't get your hopes up though. GCC isn't the best compiler out there, at least not for C++. It would be interesting to compare a hand optimized version in assembler with C#. Care to write one? ;)

                  -- Based on a True Story

                  S Offline
                  S Offline
                  Super Lloyd
                  wrote on last edited by
                  #58

                  I forget all my assembly! In fact I never passed the gap of the protected mode, that kind of stopped dead all my assembly effort :sigh:

                  1 Reply Last reply
                  0
                  • S Super Lloyd

                    it is not equal! in C++ it is just one instruction to move the stack pointer and not so in C#...

                    N Offline
                    N Offline
                    Nemanja Trifunovic
                    wrote on last edited by
                    #59

                    Super Lloyd wrote:

                    it is not equal! in C++ it is just one instruction to move the stack pointer and not so in C#...

                    Exactly :) That's one reason why C++ is faster than C#.

                    Programming Blog utf8-cpp

                    S 1 Reply Last reply
                    0
                    • N Nemanja Trifunovic

                      Super Lloyd wrote:

                      it is not equal! in C++ it is just one instruction to move the stack pointer and not so in C#...

                      Exactly :) That's one reason why C++ is faster than C#.

                      Programming Blog utf8-cpp

                      S Offline
                      S Offline
                      Super Lloyd
                      wrote on last edited by
                      #60

                      no, that's just show that you are a bad C# developer ;P

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups