Reasonable timerInterval

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Reasonable timerInterval

Post by NutJob »

I have a question about the performance of using the timer. Currently I have a timer set to 0.2 (5 /sec) so I can run a polling system on a "reasonably" heavy function (8 functions). It calculates the speed the party is traveling, to triggering self-made events at coordinates, to created racial abilities (elves hear monsters, dwarves detect hidden stonework, etc), scanning blocks around the party, and a pathing system to help determine experience gain doing puzzles, and a few other tid-bits (pun intended).

So 0.2 too fast? I'd have to recalculate some formulas but basically, my alternate question is, "Should I stick to 1.0?"

Currently I suffer no performance issues but I know scripts are interrupted so that can make all the difference for others' setups.
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: Reasonable timerInterval

Post by JohnWordsworth »

I think there are a lot of factors that could play into your decision, but if you can parameterise your scripts so that you have a value at the top "timeStep = 0.2" and use that in all of your calculations, then you can easily tweak the timerInterval later on when you know how much performance overhead the final function has and how much "free processing time" you have left over.

With that said, if you can split the function up into bits then you could split the work out. So, if you have 8 functions running, it might be good to split it into two sets of 4 and run half of the methods every 0.2 seconds to "even out the load". Other than that, you'll just have to play it by ear really. See how it goes and tweak as necessary. One thing to consider - If you can turn bits on/off as necessary or change the timer interval so that it's called less when it's needed less ie. if it only runs in certain areas of a dungeon and does nothing otherwise) then you should definitely consider that.

Oh, and don't worry too much about performance early on. I mean, if it's clearly going to be a hog - then of course. But it's better to get a dungeon finished that runs at 45fps in a few areas than never to finish it!
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: Reasonable timerInterval

Post by NutJob »

Good call on throttling (accustomed to doing that developing ajax apps) and have a good handful of things that don't need to run every poll. Really about the only thing I have to update every poll is the keyCoord which is made up of level..x..y. Having a hard time figuring out how to get my Z coordinate though.

Thanks for the direction, John.
Post Reply