Jump to content

Recommended Posts

Posted

Thanks. "timeBeginPeriod" is exactly what I needed.

It also shows that AutoIt's sleep() function is indeed hardcoded to go as low as 10ms.

Here's a new code example:

[autoit]$hDll_ntdll = DllOpen("ntdll.dll")

$hDll_winmm = DllOpen("winmm.dll")

........

.........

...........

A word of caution, directly from Microsoft, http://msdn.microsoft.com/en-us/library/windows/desktop/dd757624(v=vs.85).aspx

After 5 years absence from AutoIT, I forgot all about the SLEEP innacuracy problem. Finally figured this was what was causing me headachs, researched again SLEEP alternatives, and found that this solution worked very well for me. As coded, get as much as 3mSec average error on 1mSec accurate test time, but take the DLL call to set things up for accurate timing out of the loop and got this down to normally 50microsend accuracy, at least on my laptop. Did see some average errors up in the 100+microsecond range.

considering a CPU clock cycle is more than a 100 thousand times smaller than these time intervals, as a scientist I think this still stinks, but is good enough for the engineering part of my brain.

And yes, there are times when you want sleep to be accurate down in this time region, this time I am building a CPU stress program using a PWM type stress so I can automatically characterize PC CPU temp characteristics as a funtion of CPU stressing percentage and fan control parameters.

  • 3 years later...
Posted

Love all the comments and I'll post my final code but I was really looking to go the other way.  Sleep for 1/2 second but with almost no cpu use.

This call will work, but if there are any other trick you can think of to cool a process.... or

to turn off some of AutoIt background stuff.  I'm going for the lowest CPU when GUI is down but still monitor stuff now and then.

Thx.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...