rezecib Posted May 20, 2016 Share Posted May 20, 2016 (edited) So I've been looking at ways of optimizing geometric placement to run better on computers with different processor speeds. One idea I've been exploring is setting a "time budget" for the updates and only doing as many collision checks as it thinks it can complete in that time. However, the problem is that using os.clock() seems to be the most accurate thing I've found, and even then the accuracy only seems to be about a millisecond (and even that seems a bit unreliable), and I expect that the accuracy might actually vary between computers. Does Don't Starve (or DST's) custom Lua runtime or code have better time-keeping methods? I've only found stuff with down to tick accuracy, which isn't good enough because the idea of this optimization is to do a test to within the tick in order to guess how much it can accomplish without using up too much of the tick's 33 milliseconds. @Maris you seem to do a lot of profiling, have you found anything better? I also remember reading there's a built-in profiler, so perhaps that makes use of something more accurate. Edit: Hmm, well, in absence of that, an altered version that does chunks of updates and checks if it's gone over-budget after each chunk seems to do reasonably well at staying on-budget. But I'm still worried that os.clock() will have lower accuracy on other computers and therefore go way over budget... Edited May 20, 2016 by rezecib Link to comment Share on other sites More sharing options...
Maris Posted May 24, 2016 Share Posted May 24, 2016 You can use DoPeriodicTask(0.01, ....) which means "each tick". In your custom function you can use os.clock to check if some ticks are missed. os.clock() is the most accurate thing to get real local time. Also you can ask developers to add profiling C functions to check game percent of CPU (OS should provide this information). However, processor speed does not really matter if user have bad video card. I mean CPU usage may be low but user still have lags. You can try to summon 500 beefalos on your i5/i7 and see that CPU usage is below 100%. All you need is some kind of GetFPS() function. Ask developers to add this function into the game API, please. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now