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. Programmatic Function Profiling

Programmatic Function Profiling

Scheduled Pinned Locked Moved C / C++ / MFC
c++cssdebuggingperformance
27 Posts 9 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.
  • R Rajesh R Subramanian

    CPallini wrote:

    You should make (in)famous QueryPerformanceFrequency/QueryPerformanceCounter pair make the best (while still reliable) choiche

    Agreed. :) Hijack attempt starts: How are you doing with the Connoisseur's tea? Liking it?

    Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Microsoft MVP - Visual C++[^]

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

    Rajesh R Subramanian wrote:

    Hijack attempt starts:

    Hijack attempts goes stright on: Yes I like it. But I had few occasions to taste it again. It's quite hot these days here in Italy and I prefer lower temperatures to have cups of tea. (of course I can't miss hot coffee, but, you know, I'm an addict...) :-D

    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?

    R 1 Reply Last reply
    0
    • CPalliniC CPallini

      Rajesh R Subramanian wrote:

      Hijack attempt starts:

      Hijack attempts goes stright on: Yes I like it. But I had few occasions to taste it again. It's quite hot these days here in Italy and I prefer lower temperatures to have cups of tea. (of course I can't miss hot coffee, but, you know, I'm an addict...) :-D

      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]

      R Offline
      R Offline
      Rajesh R Subramanian
      wrote on last edited by
      #19

      CPallini wrote:

      I prefer lower temperatures to have cups of tea.

      Urgent?

      Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Microsoft MVP - Visual C++[^]

      CPalliniC T 2 Replies Last reply
      0
      • R Rajesh R Subramanian

        CPallini wrote:

        I prefer lower temperatures to have cups of tea.

        Urgent?

        Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Microsoft MVP - Visual C++[^]

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

        Yes, plz plz. Or gimme more drugz! :-D

        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?

        S 1 Reply Last reply
        0
        • CPalliniC CPallini

          Yes, plz plz. Or gimme more drugz! :-D

          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]

          S Offline
          S Offline
          SandipG
          wrote on last edited by
          #21

          And finally hijacked!! :D

          Regards, Sandip.

          R T 2 Replies Last reply
          0
          • S SandipG

            And finally hijacked!! :D

            Regards, Sandip.

            R Offline
            R Offline
            Rajesh R Subramanian
            wrote on last edited by
            #22

            :-\

            Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Microsoft MVP - Visual C++[^]

            1 Reply Last reply
            0
            • V Varghese Paul M

              Hi All, Is there a way to find out the time taken by a function to complete (in terms of nanoseconds) in my c++ code without using "Function Profiling" feature of the linker. I tried GetTickCount(), but it gives the time in milliseconds. It always returns 0 because my function completes its task less than in one millisecond. Thanks in advance

              S Offline
              S Offline
              Saurabh Garg
              wrote on last edited by
              #23

              I will suggest that you run this function a large number of times. Take the total time and the compute the average time, this way you will have more realistic measure of time function takes. -Saurabh

              1 Reply Last reply
              0
              • V Varghese Paul M

                Hi All, Is there a way to find out the time taken by a function to complete (in terms of nanoseconds) in my c++ code without using "Function Profiling" feature of the linker. I tried GetTickCount(), but it gives the time in milliseconds. It always returns 0 because my function completes its task less than in one millisecond. Thanks in advance

                enhzflepE Offline
                enhzflepE Offline
                enhzflep
                wrote on last edited by
                #24

                [EDIT] Yeah, what he said. (seems I had the reply window open longer than I thought :-O ) I don't quite understand what the big deal is - am I really missing something really obvious? This just seems like a relatively simple exercise in maths to me, with the added fun of error estimation and minimization. There's 1,000ms in a second right. So, if I can complete 2,000 events in 1,000 ms then each event is taking 1,000 / 2,000 = 0.5ms. So then if I complete something 5,000,000 times in 1,000ms, each event is taking 0.0002 ms, or 1/5,000,000 = 0.0000002s - we've already measured/calculated the time of completion to 1/5000th the resolution of the millisecond timer. Something to consider though is that as the time of each event becomes smaller and smaller, the overhead of the loop becomes a higher and higher margin of the error. The other major source of error is task-switching. This makes timing such an event in a non-realtime os more than a bit of a challenge. Things that can help you minimize these errors are to (i) kill all unnecessary processes first (ii) complete the maximum number of events you can - a longer sample time will help give more consistant results. (iii) start the timing loop on a keypress. This will allow you to start your program, set it's priority to "realtime" and then get timing. Lets say I have a loop that calls my function 14 times per iteration(inlining the code would be much better than calling a function of course). Next, I time 500 million iterations of my loop and find that it completes in 2785 ms. So, I can tell that I'm getting 179,533.2136 loop iterations per millisecond. I then multiply this by 14 and find that I'm getting 2,513,464 function calls per millisecond. This would correspond to 2.5 function calls per nanosecond. (not a result you could hope to get close to, given current clock-rates of cpus and the error-inducing factors I mentioned above, but that's the basic idea)

                1 Reply Last reply
                0
                • R Rajesh R Subramanian

                  CPallini wrote:

                  I prefer lower temperatures to have cups of tea.

                  Urgent?

                  Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Microsoft MVP - Visual C++[^]

                  T Offline
                  T Offline
                  ThatsAlok
                  wrote on last edited by
                  #25

                  cup of coffee also help :)

                  "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
                  Never mind - my own stupidity is the source of every "problem" - Mixture

                  cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/xml>

                  1 Reply Last reply
                  0
                  • S SandipG

                    And finally hijacked!! :D

                    Regards, Sandip.

                    T Offline
                    T Offline
                    ThatsAlok
                    wrote on last edited by
                    #26

                    SandipG wrote:

                    And finally hijacked!!

                    Whom??

                    "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
                    Never mind - my own stupidity is the source of every "problem" - Mixture

                    cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/xml>

                    1 Reply Last reply
                    0
                    • CPalliniC CPallini

                      Rajesh R Subramanian wrote:

                      In the best case, the HAL may conclude that the RDTSC counter runs at a constant frequency, so it uses that instead.

                      That's API robustness. You should make the (in)famous QueryPerformanceFrequency/QueryPerformanceCounter pair make the best (while still reliable) choiche for you. ;)

                      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]

                      T Offline
                      T Offline
                      ThatsAlok
                      wrote on last edited by
                      #27

                      CPallini wrote:

                      QueryPerformanceFrequency/QueryPerformanceCounter pair make the best (while still reliable) choiche for you

                      damm i missed it!

                      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
                      Never mind - my own stupidity is the source of every "problem" - Mixture

                      cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/xml>

                      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