Click here to Skip to main content
15,886,110 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: VC++ and Empty Base Class Optimization problem/bug Pin
Matthew Faithfull15-Mar-13 6:36
Matthew Faithfull15-Mar-13 6:36 
GeneralRe: VC++ and Empty Base Class Optimization problem/bug Pin
David Crow15-Mar-13 7:34
David Crow15-Mar-13 7:34 
GeneralRe: VC++ and Empty Base Class Optimization problem/bug Pin
Kosta Cherry15-Mar-13 8:45
Kosta Cherry15-Mar-13 8:45 
AnswerRe: VC++ and Empty Base Class Optimization problem/bug Pin
jschell15-Mar-13 8:56
jschell15-Mar-13 8:56 
QuestionHow Can I set Noise In Image ? Pin
002comp14-Mar-13 19:25
002comp14-Mar-13 19:25 
AnswerRe: How Can I set Noise In Image ? Pin
Marco Bertschi14-Mar-13 22:21
protectorMarco Bertschi14-Mar-13 22:21 
AnswerRe: How Can I set Noise In Image ? Pin
nv316-Mar-13 2:16
nv316-Mar-13 2:16 
QuestiontimeGetTime() is unreliable on my computer too, not monotonic! Pin
Robert Inventor14-Mar-13 18:04
Robert Inventor14-Mar-13 18:04 
Hope you don't mind me posting this as a second question, but wanted to catch attention of anyone who is especially knowledgeable about timeGetTime as well.

Here is the simple code I'm using:

C++
DWORD dwt=timeGetTime();
static DWORD dwt_was;
if(dwt_was!=0)
if(dwt<dwt_was)
 dwt=dwt;
dwt_was=dwt;


Also - it's not the timer wrap around

I have just got it here set a break point on the dwt-dwt line and it shows:

dwt_was 54493247
dwt 54493246

How can timeGetTime() go backwards in time?

In case it is relevant this is on a Lenovo Thinkpad Edge e520

ALL FIVE TIMERS ARE INACCURATE - even when they are constrained to a single core:

GetSystemTimeAsFileTime(..)
timeGetTime()
GetTickCount()
QueryPerformanceCounter()
RTDSC()

They all jump back in time frequently on this machine. I have tested them all constrained to a single core.

The only thing I can think of is to try a best guess averaging process as described in this article but not convinced it will be much of an improvement or worth the work involved:

http://www.mindcontrol.org/~hplus/pc-timers.html[^]



Discussion here

http://devmaster.net/forums/topic/4670-need-help-with-queryperformancecounter-and-dual-processors/[^]
On the whole it works reasonably well most of the time. Only now and again get these glitches, they go back in time perhaps every second or two, by a ms or two - and with the metronome typically only playing a few notes per second at most, the chance of hitting a major glitch is fairly small.

I think that's the only reason that it is working as a functional metronome on my computer. It's actually pretty good, but wanted to make it more accurate than it is already.

Also this two discussion:

http://stackoverflow.com/questions/2904887/sub-millisecond-precision-timing-in-c-or-c[^]

There's also the KeQueryPerformanceCounter but I think that might just be for writers of Drivers - and with all the other ones not working don't know if it would fix the issue anyway.

There's the Windows timestamp project here:
href="http://windowstimestamp.com/description
[^]

but it seems to be work in progress, don't think you can actually use it in your apps yet??

If it can't be fixed, I'm also interested in any setting I can ask the user to set on their computer if they want to have the highest possible accuracy of timing? E.g. to switch off some power saving frequency adjusting feature or something?

The only other thing I can think of is to write to midi, convert the midi to audio, and play the audio - that is well timed, but not possible to do in real time.

(sorry forgot you can edit these posts - hence all those deleted extra messages below).

modified 15-Mar-13 3:39am.

AnswerMessage Closed Pin
14-Mar-13 18:15
Robert Inventor14-Mar-13 18:15 
GeneralMessage Closed Pin
14-Mar-13 18:20
Robert Inventor14-Mar-13 18:20 
GeneralMessage Closed Pin
14-Mar-13 18:53
Robert Inventor14-Mar-13 18:53 
GeneralMessage Closed Pin
14-Mar-13 19:19
Robert Inventor14-Mar-13 19:19 
AnswerRe: timeGetTime() is unreliable on my computer too, not monotonic! Pin
Robert Inventor19-Mar-13 7:31
Robert Inventor19-Mar-13 7:31 
QuestionQueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
Robert Inventor14-Mar-13 15:50
Robert Inventor14-Mar-13 15:50 
AnswerRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
Robert Inventor14-Mar-13 18:07
Robert Inventor14-Mar-13 18:07 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
dusty_dex15-Mar-13 0:24
dusty_dex15-Mar-13 0:24 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
Robert Inventor18-Mar-13 14:44
Robert Inventor18-Mar-13 14:44 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
dusty_dex18-Mar-13 22:08
dusty_dex18-Mar-13 22:08 
AnswerRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
Robert Inventor19-Mar-13 6:19
Robert Inventor19-Mar-13 6:19 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
dusty_dex19-Mar-13 8:34
dusty_dex19-Mar-13 8:34 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
Robert Inventor20-Mar-13 10:10
Robert Inventor20-Mar-13 10:10 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
Robert Inventor20-Mar-13 11:12
Robert Inventor20-Mar-13 11:12 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
dusty_dex20-Mar-13 11:18
dusty_dex20-Mar-13 11:18 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
Robert Inventor20-Mar-13 12:15
Robert Inventor20-Mar-13 12:15 
QuestionHelp in Win32 programming with c++ Pin
naseer86114-Mar-13 8:44
naseer86114-Mar-13 8:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.