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. General Programming
  3. C / C++ / MFC
  4. Which is faster?

Which is faster?

Scheduled Pinned Locked Moved C / C++ / MFC
helpperformancequestioncssdiscussion
24 Posts 6 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.
  • C Code o mat

    I used a debug build to avoid optimisations, and the compiler comes from VS2003 (i know, i know, it's old...)

    > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

    A Offline
    A Offline
    Aescleal
    wrote on last edited by
    #15

    Doesn't switching the optimiser off defeat the idea of having an optimising compiler? And I wouldn't worry about using VC++ 2003. It's under 10 years old and actually supports a reasonable amount of the C++ 98 standard unlike all the numpties who painted themselves into a corner using VC++ 6 and now can't move off it because they were programming to MS's standard. Cheers, Ash

    C CPalliniC 2 Replies Last reply
    0
    • A Aescleal

      Doesn't switching the optimiser off defeat the idea of having an optimising compiler? And I wouldn't worry about using VC++ 2003. It's under 10 years old and actually supports a reasonable amount of the C++ 98 standard unlike all the numpties who painted themselves into a corner using VC++ 6 and now can't move off it because they were programming to MS's standard. Cheers, Ash

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #16

      As said here[^], probably the compiler modifies the code to its likes to produce the -possibly- fastest way to do it. Which kinda renders the whole question obsolete i guess, since no matter how i do it the result will be the same, or at least, which is faster will depend on the used compiler/optimization method. So i'd say, turning off optimizations is only important from the "hypothetical question's" point of view.

      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

      1 Reply Last reply
      0
      • C Code o mat

        Try with optimizations turned off.

        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

        D Offline
        D Offline
        Druuler
        wrote on last edited by
        #17

        they were disabled...

        C 1 Reply Last reply
        0
        • D Druuler

          they were disabled...

          C Offline
          C Offline
          Code o mat
          wrote on last edited by
          #18

          That's odd...

          > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

          1 Reply Last reply
          0
          • A Aescleal

            Doesn't switching the optimiser off defeat the idea of having an optimising compiler? And I wouldn't worry about using VC++ 2003. It's under 10 years old and actually supports a reasonable amount of the C++ 98 standard unlike all the numpties who painted themselves into a corner using VC++ 6 and now can't move off it because they were programming to MS's standard. Cheers, Ash

            CPalliniC Offline
            CPalliniC Offline
            CPallini
            wrote on last edited by
            #19

            Aescleal wrote:

            Doesn't switching the optimiser off defeat the idea of having an optimising compiler?

            And the whole point of a speed test, I would say. :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            In testa che avete, signor di Ceprano?

            1 Reply Last reply
            0
            • C Code o mat

              In case you care, i did the testing, here are[^] the results.

              > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

              CPalliniC Offline
              CPalliniC Offline
              CPallini
              wrote on last edited by
              #20

              Yes, I can care. Anyway I wouldn't use a debug build for a speed test. :)

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              In testa che avete, signor di Ceprano?

              C 1 Reply Last reply
              0
              • CPalliniC CPallini

                Yes, I can care. Anyway I wouldn't use a debug build for a speed test. :)

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                [My articles]

                C Offline
                C Offline
                Code o mat
                wrote on last edited by
                #21

                Just for you ( :) ), here are the results of a release build with "default" optimization (for speed): <1a> 0.0000022349 sec <1b> 0.0000019556 sec <2 > 0.0000019556 sec ---------- <1a> 0.0000016762 sec <1b> 0.0000016762 sec <2 > 0.0000016762 sec ---------- <1a> 0.0000016762 sec <1b> 0.0000016762 sec <2 > 0.0000016762 sec ---------- <1a> 0.0000016762 sec <1b> 0.0000016762 sec <2 > 0.0000019556 sec ---------- <1a> 0.0000016762 sec <1b> 0.0000016762 sec <2 > 0.0000019556 sec and with optimizations turned off: <1a> 0.7622823571 sec <1b> 0.7618152586 sec <2 > 0.5077494486 sec ---------- <1a> 0.7632852779 sec <1b> 0.7537491497 sec <2 > 0.5121279380 sec ---------- <1a> 0.7620644523 sec <1b> 0.7755153239 sec <2 > 0.5118524840 sec ---------- <1a> 0.7574504581 sec <1b> 0.7570453787 sec <2 > 0.5195719009 sec ---------- <1a> 0.7594526679 sec <1b> 0.7610942173 sec <2 > 0.5190137294 sec [EDIT] I wonder where the "variance" of the time needed for the 2nd method comes from with optimizations applied.

                > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

                CPalliniC 1 Reply Last reply
                0
                • C Code o mat

                  Just for you ( :) ), here are the results of a release build with "default" optimization (for speed): <1a> 0.0000022349 sec <1b> 0.0000019556 sec <2 > 0.0000019556 sec ---------- <1a> 0.0000016762 sec <1b> 0.0000016762 sec <2 > 0.0000016762 sec ---------- <1a> 0.0000016762 sec <1b> 0.0000016762 sec <2 > 0.0000016762 sec ---------- <1a> 0.0000016762 sec <1b> 0.0000016762 sec <2 > 0.0000019556 sec ---------- <1a> 0.0000016762 sec <1b> 0.0000016762 sec <2 > 0.0000019556 sec and with optimizations turned off: <1a> 0.7622823571 sec <1b> 0.7618152586 sec <2 > 0.5077494486 sec ---------- <1a> 0.7632852779 sec <1b> 0.7537491497 sec <2 > 0.5121279380 sec ---------- <1a> 0.7620644523 sec <1b> 0.7755153239 sec <2 > 0.5118524840 sec ---------- <1a> 0.7574504581 sec <1b> 0.7570453787 sec <2 > 0.5195719009 sec ---------- <1a> 0.7594526679 sec <1b> 0.7610942173 sec <2 > 0.5190137294 sec [EDIT] I wonder where the "variance" of the time needed for the 2nd method comes from with optimizations applied.

                  > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

                  CPalliniC Offline
                  CPalliniC Offline
                  CPallini
                  wrote on last edited by
                  #22

                  Thank you, sir. :)

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                  [My articles]

                  In testa che avete, signor di Ceprano?

                  1 Reply Last reply
                  0
                  • A Aescleal

                    The only way to find out is to write some tests, compile and run them on your system. Arguing thoretically about what's faster is fairly pointless. Cheers, Ash

                    M Offline
                    M Offline
                    Member 4194593
                    wrote on last edited by
                    #23

                    Wrong. The only way is to create the .COD file and see what the compiler generates for that code, then with a debugger, see what load time optimization may be done during loading. It is this final machine code that tells the story during execution. Dave.

                    A 1 Reply Last reply
                    0
                    • M Member 4194593

                      Wrong. The only way is to create the .COD file and see what the compiler generates for that code, then with a debugger, see what load time optimization may be done during loading. It is this final machine code that tells the story during execution. Dave.

                      A Offline
                      A Offline
                      Aescleal
                      wrote on last edited by
                      #24

                      CAVEAT: This doesn't apply if you're talking about embedded systems where you have a greater degree of control over what's running. On your average desktop looking at an assembly listing won't tell you how fast a piece of code runs. It might give you an idea, might even tell you some idea of the relative speed [1] and where you could speed it up if you wanted to manually code it but won't tell you how fast it actually runs. As for "load time optimisation" I'm not sure what you mean in this context but load time shouldn't be a factor in measuring how fast a particular lump of code runs. Load time is long over by the time you start measuring how fast a particular piece of code runs. Cheers, Ash

                      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