Bnae 1427 Posted March 14, 2016 Hello, I'm trying to make lightweight loop to check if the conditions are met. In my case the condition in weather. Since it's so unlikely that it's going to rain so heavily, i don't wan't that this loop will effect on the FPS to much. I could make for _i or waituntil to check the conditions, but i'm hoping for something even more lightweight. fn_rain = { _rain = rain; if (_rain > .95) then { SOMEFUNCTION; } else { SOMEFUNCTION; }; }; else is only to disable if necessary By Killzone_Kid for "_i" from 0 to 1 step 0 do {}; //will run infinitely This is one way of course. Any ideas? Share this post Link to post Share on other sites
austin_medic 104 Posted March 14, 2016 Hello, I'm trying to make lightweight loop to check if the conditions are met. In my case the condition in weather. Since it's so unlikely that it's going to rain so heavily, i don't wan't that this loop will effect on the FPS to much. I could make for _i or waituntil to check the conditions, but i'm hoping for something even more lightweight. fn_rain = { _rain = rain; if (_rain > .95) then { SOMEFUNCTION; } else { SOMEFUNCTION; }; }; else is only to disable if necessary By Killzone_Kid for "_i" from 0 to 1 step 0 do {}; //will run infinitely This is one way of course. Any ideas? Any performance impact is going to be completely negligible, and you are wasting your time nitpicking these small things most likely, depending on specifics of mission, but you know what really swallows up lots of CPU cycles? AI. Checking condition each frame may seem like it will compeletly destory the game, but no that is actually NOT the case. A check takes very few cycles (and CPUs are very fast - i7 6700k can do 161,173 Million Instructions Per Second at 4.0 GHz, 4770 can do about 30k less than that, and of course extreme editions stomp on both of the consumer cpu's.), much much less than AI does. However you do it in the end won't matter really unless your spawning thousands and thousands of the function all at once. Then YES it will wreck your mission. Share this post Link to post Share on other sites
Bnae 1427 Posted March 14, 2016 Hello austin_medic. Since at the moment in my server there is 200 functions (and more to come) running depending what you do, i want to assure the best possible experience for all the users. And yes, i have 4690k 4.5GHz, and my FPS while playing in my server is proximately 75-85. And i want to keep it that way by not making foolish functions burden everyone's CPUs. Thanks for your answer. Share this post Link to post Share on other sites
gc8 579 Posted March 14, 2016 Sleep function is best way to optimize your code. while {true} do { sleep 2; // sleep long as feasible }; Share this post Link to post Share on other sites
Bnae 1427 Posted March 14, 2016 Sleep function is best way to optimize your code. while {true} do { sleep 2; // sleep long as feasible }; It's looping with while command at the moment. Thanks gc8 for bringing that up if somebody else reads this. Share this post Link to post Share on other sites