Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
I am finding that FreePIE's clock rate changes. I think it may be to do with speedstep (processor throttling).
When I first start FreePIE it's at about 60Hz, but after running it for a while it shifts up to 1000Hz. It appears to coincide with my CPU speed changing from 1000GHz to 3000GHz.
What rate is FreePIE supposed to run at?
The default rate is 64hz not including the overhead of the script it self. And you must take into account hat windows is not a real time system.
Timing in FreePIE is not easy, we cant just let the script have all CPU time it can get because then we will throttle that Core and you will run into performance problem. So we have a pattern for timing the script cycle. Default we use the system clock which is at 64hz. You can override this using system.setThreadTiming and system.threadExecutionInterval
We have some different strategies for timing, if you know C# you can check them out here
If you want the most accurate one (If we ignore that Windows is not a real time system and that FreePIE is managed code) you should use TimingTypes.ThreadYieldMicroSeconds. It will however eat more resources than for example TimingTypes.HighresSystemTimer
From what I can work out:
Is there not just a simple timer that calls Thread.Sleep for the right amount of time, taking into account how much time the script took?
Also, the default ThreadExecutionInterval is 1, which would mean a default rate of 1000Hz. Where does the 64Hz come from? My suspicion at the moment is that this is not really defined properly, and is instead just rate limited by the thread scheduler or something.
None of the strategies take into account the time taken for the script sadly. Shouldn't be a problem in normal cases though since the overhead in the script should be minimal. The system clock runs at 64hz, so you can't sleep shorter than 16ms (1000/64). Really strange that you get 1000hz, do you have another program that changes the speed of the system clock? That's how the Highres strategy work, it changes the system clock from 64hz to 1000hz