RoboMat Posted July 29, 2013 Share Posted July 29, 2013 Okay so with the new events like EveryTenMinutes we aready have a powerful Event which doesn't eat much performance. I still have questions about the performance though. Would there be any difference betweenfunction one()...end function two()...end function three()...end Events.EveryTenMinutes.Add(one);Events.EveryTenMinutes.Add(two);Events.EveryTenMinutes.Add(three);and:function one()...end function two()...end function three()...end function master() one() two() three()end Events.EveryTenMinutes.Add(master);Will there be any noticeable impact if I exit out of the functions early? I actually do that at the moment in all of my mods... I try to exit out as soon as possible by testing different boolean states at the beginning of the function for example. For example like this:function doStuff() if noStuffToDo then return; end... -- else do much more stuff hereendEvents.OnTick.Add(doStuff);Of course it has to check the boolean value each time it is called but would this have any recogniseable impact on performance or is it negligeable? Link to comment Share on other sites More sharing options...
Aricane Posted July 29, 2013 Share Posted July 29, 2013 Okay so with the new events like EveryTenMinutes we aready have a powerful Event which doesn't eat much performance. I still have questions about the performance though. Would there be any difference betweenfunction one()...end function two()...end function three()...end Events.EveryTenMinutes.Add(one);Events.EveryTenMinutes.Add(two);Events.EveryTenMinutes.Add(three);and:function one()...end function two()...end function three()...end function master() one() two() three()end Events.EveryTenMinutes.Add(master);Will there be any noticeable impact if I exit out of the functions early? I actually do that at the moment in all of my mods... I try to exit out as soon as possible by testing different boolean states at the beginning of the function for example. For example like this:function doStuff() if noStuffToDo then return; end... -- else do much more stuff hereendEvents.OnTick.Add(doStuff);Of course it has to check the boolean value each time it is called but would this have any recogniseable impact on performance or is it negligeable?Hmm good question. OnTick is very dangerous to use with average complex functions I think. I'm counting tick and for every tenth, I do the functionality to avoid fps drops Link to comment Share on other sites More sharing options...
7Roses Posted July 29, 2013 Share Posted July 29, 2013 good questions, I guess the first part about 3 events or 1 even isn't going to make much difference on your performance. the second part, about exiting as soon as possible is a good coding rule you should indeed do.the time used for testing 1 boolean isn't so great and I guess is indeed negligeable. also on the OnTick thingy, if it doesn't need to be used EVERY tick it is indeed possible to use something like if (somecounterfromsomewhere mod 20 == 0) then ...... endps. arcane you just wrote that message at the moment I did to Link to comment Share on other sites More sharing options...
RoboMat Posted July 29, 2013 Author Share Posted July 29, 2013 Thanks for your replies fellas OnTick was just an example I haven't used it yet because the EveryTenMinutes Event was sufficient for my needs so far But the counter is a great idea. Link to comment Share on other sites More sharing options...
lemmy101 Posted July 29, 2013 Share Posted July 29, 2013 The difference would be so negligible so as not worth worrying about tbh... Stay away from using OnTick if possible for any 'gameplay stuff' if every ten minutes will work for you, since tick is every game update regardless of game speed, and you'd need to factor the game speeds in yourself. Link to comment Share on other sites More sharing options...
johndough Posted July 30, 2013 Share Posted July 30, 2013 The only events I've noticed dragging down the performance on my old laptop are the draw events. And it usually takes a lot of for loops to do it. Still, it would be nice to have an EverySecond event. EveryTenMinutes is usually too infrequent and OnTick too frequent. Link to comment Share on other sites More sharing options...
7Roses Posted August 21, 2013 Share Posted August 21, 2013 and a onUpdatePlayer how frequent is that been fired lemmy? (or other devs/knowledgedatabases) 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