News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Accurate 10 ms timer using the multimedia APIs.

Started by hutch--, October 02, 2005, 09:09:49 AM

Previous topic - Next topic

hutch--

Here is a very simple demo on how to use the multimedia APIs to produce precision results in conjunction with the SleepEx() API. It has been tested on a machine that is almost at idle and it uses about 5% processor while running. The surprising thing was the SleepEx() API is a lot higher precision than I expected where the main lag was repeatedly retrieving the time from the OS. The winmm library has a number of functions that make this a far more reliable operation.

It would be expected that if the machine was subject to a heavy processor load that the precision would drop but tis will be the case with any other periodic process running on the machine.

[attachment deleted by admin]
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Codewarp

Hutch,

I have found that I can get timing with better than 1 microsecond accuracy by taking the ratio of two functions from windows.h:

    QueryPerformanceCounter( ) / QueryPerformanceFrequency( )

I base this conclusion on comparing its result against the cpu clock cycles sampled for the same period, on a cpu running at a known frequency.