Re: Real time clock with millisecond resolution <newb>

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




"Hunter" <Igal.Hunter@xxxxxxxxx> wrote in message
news:1188220541.699045.103270@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi all,

Please forgive me for my newbie question. It's just that I've run out
of options, so I'm posting my question here.
What I need is to implement a time-stamping mechanism, and I need the
time to be in millisecond resolution. I tried my best with the
standard ansi C functions, but the best I could get was a real-time
clock with seconds.
However, I was given a good advice, to try and look for something
system-specific that would provide me with a calendar-time clock with
millisecond resolution and precision.

If anyone knows how I can access calendar time with a resolution as
high as millisecond, and similar precision, I'll appreciate the help.
Please write your answer as simple as possible, as I'm not a
professional programmer, so my C skills are a limited.

My system is a Desktop running Win2000, I have a Visual C++ 6.0

I implemented a Windows version of gettimeofday. What I did was to get the
current system time (to the nearest second) and also call
QueryPerformanceCounter. Then I arbitrarily choose that the milliseconds
are zero at that time. Later, calling QueryPerformanceCounter again gives
you very high resolution elapsed time, which you can add to your original
system time to get a high resolution calendar time.

The only drawback with that is that the extra resolution isn't shared
between processes. But for most cases, like if you just need extra
precision in your debug log, it's great. Computer time can't be expected to
be synchronized to any external source with better than +/- 1 second anyway.


Thank you very much.



.



Relevant Pages

  • Re: Timer resolution
    ... You can set resolution to 1 mscek with Multimedia Timers( ... timeBeginPeriod/timeEndPeriod) in desktop windows but that will not be ... > to get real system time with 1ms resolution. ... > KeQueryPerformanceCounter once when the driver first completes a frame ...
    (microsoft.public.development.device.drivers)
  • W32Time Event Type: Warning
    ... resolution is not relevant because I'm XP SP2 with all recommended update ... The time service has not been able to synchronize the system time for 49152 ... time stamp. ...
    (microsoft.public.windowsxp.general)
  • Re: [PATCH] msleep() with hrtimers
    ... If the millisecond resolution is enough for these users, ... current msleep will work fine for them. ... Timers are course resolution that is highly HZ-value dependent. ...
    (Linux-Kernel)
  • Re: Replacing the ProJect 8.6 tonearm cable
    ... Another newbie question. ... factory fitted cables that come connected to the Project ... Rotel CD player fitted with some mid-range Taralabs ... Detail usually relates to resolution, ...
    (uk.rec.audio)
  • Re: Get system time in Milliseconds
    ... GetTickCountor performance counters. ... state you shouldn't count on these functions for sub-second resolution. ... the time of another with accuracy upto milliseconds. ... suggest any alternatives how to get system time with actual milliseconds. ...
    (microsoft.public.windowsce.app.development)