flat assembler
Message board for the users of flat assembler.

Index > Windows > Time measurements jump

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 831
Roman
I use timeGetTime.
My time jump from 25 ms to 15 ms ! How fix this ?
Windows 7
My video:
http://www.youtube.com/watch?v=VRQ3m7SrS5I
Post 17 Jan 2014, 16:23
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17717
Location: In your JS exploiting you and your system
revolution
Roman wrote:
I use timeGetTime.
My time jump from 25 ms to 15 ms ! How fix this ?
Windows 7
My video:
http://www.youtube.com/watch?v=VRQ3m7SrS5I
I didn't watch the video so I don't know if it is relevant but to answer your question in text: You can't "fix" it. It is by design. The system time-slice is about 10ms or so and the time measurements returned by APIs such as timeGetTime cannot return any higher resolution that that.

If you want a high precision timer there are other APIs available like QueryPerformanceCounter.
Post 17 Jan 2014, 16:35
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 831
Roman
QueryPerformanceCounter gives the same result Sad
Problem in Windows. Windows switches to streams and programms.
Post 17 Jan 2014, 16:47
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 831
Roman
Fasm compiled my programm to RealTime priority. But its not help.
Post 17 Jan 2014, 16:48
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17717
Location: In your JS exploiting you and your system
revolution
Roman wrote:
Fasm compiled my programm to RealTime priority. But its not help.
Did you understand my first reply post? You can't change the time-slice frequency by changing priorities. You need to contact MS and explain your problem to them and see if they want to increase the resolution.
Post 17 Jan 2014, 17:00
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17717
Location: In your JS exploiting you and your system
revolution
Roman wrote:
QueryPerformanceCounter gives the same result
I am surprised by this result. Are you sure you are using it correctly?
Post 17 Jan 2014, 17:01
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 831
Roman
revolution
QueryPerformanceCounter measures time in nanoseconds.
QueryPerformanceCounter gives more precise time.
But Windows jump to another streams and programms and this gives trash Milliseconds.

If I used the wrong QueryPerformanceCounter i would have received is not correct time. But i get the same time as gives timeGetTime. The only difference is QueryPerformanceCounter gives milliseconds and nanoseconds.
Post 17 Jan 2014, 17:09
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17717
Location: In your JS exploiting you and your system
revolution
QPC is for short times. Trying to use it for long times will give problems as you saw.

Besides the crystals oscillators used in the mobo are not precise enough to give high resolution times over long periods. This is physical attribute that can't be fixed by software.
Post 17 Jan 2014, 17:13
View user's profile Send private message Visit poster's website Reply with quote
Frank



Joined: 17 Jun 2003
Posts: 100
Frank
Did you try this already:

Quote:
You can use the timeBeginPeriod and timeEndPeriod functions to increase the precision of timeGetTime.


Source: http://msdn.microsoft.com/en-us/library/windows/desktop/dd757629%28v=vs.85%29.aspx

If not, then also look up the timeGetDevCaps function, it gives you the system's supported resolutions (minimum, and maximum) in milliseconds.
Post 17 Jan 2014, 17:53
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 831
Roman
Frank
Yes. I use timeBeginPeriod 1 and timeEndPeriod
I read about this in msdn. But this not help me. Sad

I try invoke timeGetDevCaps,GG,8
And get Min=1 and Max=1000000
Post 17 Jan 2014, 18:34
View user's profile Send private message Reply with quote
Frank



Joined: 17 Jun 2003
Posts: 100
Frank
Strange.

I use timeGetTime for response time measurement in psychology experiments. The datasets show fine-grained response times: I see 427ms, 428ms, 429ms, and so on. Not multiples of higher values (such as 10ms or 15ms).

As a high-level overview: I start with timeGetDevCaps to find Window's minimum resolution, then I set it with timeBeginPeriod. Next come SetPriorityClass (to HIGH_PRIORITY_CLASS) and SetThreadPriority (to THREAD_PRIORITY_TIME_CRITICAL). This is for the program as a whole. The response times are then measured as the difference between two timeGetTime results.

Two more things are possibly relevant. First, in addition to timeGetTime, I use timeSetEvent for various timeout timers in the program (not during the actual measurement, but close-by). Perhaps that is somehow needed as an enabling condition that I accidentally got right? Second, my program (and the whole computer) has literally nothing else to do during the time measurement, it simply waits for a key press or mouse movement. Your program seems much more busy. Can you perhaps try these timing things without graphics-heavy loads?
Post 17 Jan 2014, 19:12
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 831
Roman
Frank and revolution
Thanks !
My videocapture prog (Debut Video Capture Software) saved mpeg4 video and for this reason time jumps !

I test my programm without Debut Video Capture Software and get stable 16~15 milliseconds !
Post 18 Jan 2014, 21:14
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.