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. Need "measuring time" suggestion

Need "measuring time" suggestion

Scheduled Pinned Locked Moved C / C++ / MFC
hardwarequestion
6 Posts 4 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.
  • J Offline
    J Offline
    J B 0
    wrote on last edited by
    #1

    Hi guys, in my software I need to measure time duration between two hardware signals (which come via RS232 connection). And I'd need that with accuracy to millisecond. I'm wondering what's a reasonably good way (meaning good accurate results) to go about it? I'm now only thinking of using SetTimer() and KillTimer() with a counter variable to count the time, would that be able to provide a good accuracy? Thanks

    L C J 3 Replies Last reply
    0
    • J J B 0

      Hi guys, in my software I need to measure time duration between two hardware signals (which come via RS232 connection). And I'd need that with accuracy to millisecond. I'm wondering what's a reasonably good way (meaning good accurate results) to go about it? I'm now only thinking of using SetTimer() and KillTimer() with a counter variable to count the time, would that be able to provide a good accuracy? Thanks

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      QueryPerformanceCounter does a good job. Take a look at this article. regards

      1 Reply Last reply
      0
      • J J B 0

        Hi guys, in my software I need to measure time duration between two hardware signals (which come via RS232 connection). And I'd need that with accuracy to millisecond. I'm wondering what's a reasonably good way (meaning good accurate results) to go about it? I'm now only thinking of using SetTimer() and KillTimer() with a counter variable to count the time, would that be able to provide a good accuracy? Thanks

        C Offline
        C Offline
        Curi0us_George
        wrote on last edited by
        #3

        One way would be to use either the _ftime() or _ftime64() function. e.g. __int64 getCurrentMilliTime() { __timeb64 time; _ftime64(&time); __int64 seconds = (__int64)time.time; return (seconds * 1000) + time.millitm; } _ftime()/_ftime64()

        1 Reply Last reply
        0
        • J J B 0

          Hi guys, in my software I need to measure time duration between two hardware signals (which come via RS232 connection). And I'd need that with accuracy to millisecond. I'm wondering what's a reasonably good way (meaning good accurate results) to go about it? I'm now only thinking of using SetTimer() and KillTimer() with a counter variable to count the time, would that be able to provide a good accuracy? Thanks

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

          On NT/W2K/XP, you can use GetTickCount() Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

          C J 2 Replies Last reply
          0
          • J Joe Woodbury

            On NT/W2K/XP, you can use GetTickCount() Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

            C Offline
            C Offline
            Curi0us_George
            wrote on last edited by
            #5

            I'll have to remember that one. That's a bit more friendly than the method I gave. (Though not as useful if you actually want the time. ;))

            1 Reply Last reply
            0
            • J Joe Woodbury

              On NT/W2K/XP, you can use GetTickCount() Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

              J Offline
              J Offline
              J B 0
              wrote on last edited by
              #6

              thanks alot guys, very helpful

              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