Comments (8)
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
https://github.com/AndersMalmgren/FreePIE/tree/master/FreePIE.Core/ScriptEngine/ThreadTiming
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 freepie.
Also,
diagnostics.watch(prevTime)
diagnostics.watch(now)
diagnostics.watch(fps)
will real time update UI, this will impact performance (While UI is in focus)
from freepie.
Thanks that's helpful, looks like some of the other timing strategies should solve the problem.
I still don't understand why the timing changes though, even with the default timing strategy. How does it end up at 1000Hz?!
from freepie.
From what I can work out:
SystemTimer
sleeps for ThreadExecutionInterval milliseconds, without regard for how long the script tookThreadYield
repeatedly yields in a spin loop until enough time has passed (I think it takes account of script time but not entirely sure)ThreadYieldMicroSeconds
same as aboveHighresSystemTimer
(BeginPeriodSystemTimerStrategy
) - I don't understand what this is doing
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.
from freepie.
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
from freepie.
Sorry, the yield strategies do take into account the time of the script :)
from freepie.
Ok. May I suggest that the default threadExecutionInterval
be set to 16 then? That would avoid the confusing behaviour in the case that the clock rate isn't 64Hz for some reason! :)
from freepie.
Could have side effects on systems that override default clock speeds.
edit: Basicly Thread.Sleep(1) means that you sleep as short time as the OS lets you.
from freepie.
Related Issues (20)
- Time not imported? HOT 2
- How to change (or duplicate) joystick input? HOT 2
- PWM Function
- vJoy version of Driver (219) does NOT match DLL Version (218) HOT 7
- How to setAxis on virtual Xbox Controller
- How i can get force feedback data HOT 18
- Script to use Mouse Scroll or Incremental Rotary encoder to Steering Wheel Accurately HOT 1
- [Suggestion] Logitech G API HOT 2
- FreePIE is not launching anymore HOT 6
- Cannot access CORE file HOT 3
- Request: Make multiple mouse Input HOT 3
- support for ar glasses HOT 3
- How do I output DSU/UDP data from freepie HOT 3
- opentrack connect but doesnt track properly it keep twitching
- Pause key not working
- Add a way to identify joystick device by name HOT 4
- 我的Freepie无法正常运行代码 HOT 6
- Add method to speech to list voices
- freepie_io_x64.dll HOT 1
- Compile script to standalone executable? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from freepie.