riouken 15 Posted May 30, 2013 :cool:hmm 5 years php 2 years c# and u re telling me that it do what its supposed to do ? ...wow ....thank you when user decide to limit both score and time.... what u will do ? ....if u will stick with that u will end up with another loop... and prove me that not... so... why two loops ? u re simply ignoring what the code says.. its hard then...... Maybe english isn't your first language and that is the communication problem. Have fun... Share this post Link to post Share on other sites
dmarkwick 261 Posted May 30, 2013 Yes I do but i'm afraid you're missing the point.There is no need to check an if statement you know it to be true... that is where the real processing time come from. There is no need to put an if statement in a loop unless you need to check the statement each iteration. At the risk of unnecessarily extending a thread that has more-or-less been resolved: what the code is doing is unimportant, the point of the examples is to find out if a conditional that looks like "if (true)" takes as long as "if (1>0)". That's all. What the code is doing, whether it makes sense or not, NOT the point. Only speed of conditional. Share this post Link to post Share on other sites
Simas 12 Posted May 30, 2013 Check this out:http://community.bistudio.com/wiki/waitUntil I would not use that function, ever. At least not without a sleep in between. My understanding is that waitUntil evaluates the condition statement every frame. That means 60 times per second if you are running at 60 fps. Share this post Link to post Share on other sites
killzone_kid 1330 Posted May 30, 2013 At the risk of unnecessarily extending a thread that has more-or-less been resolved: what the code is doing is unimportant, the point of the examples is to find out if a conditional that looks like "if (true)" takes as long as "if (1>0)". That's all. What the code is doing, whether it makes sense or not, NOT the point. Only speed of conditional. in my experiment the speed of condition varied depending on what values have been compared and having boolean was not always faster. riouken is correct if you want to optimise you have to do it with concrete task in mind not theoretically, it is just the nature of the beast. Share this post Link to post Share on other sites
dmarkwick 261 Posted May 30, 2013 in my experiment the speed of condition varied depending on what values have been compared and having boolean was not always faster. riouken is correct if you want to optimise you have to do it with concrete task in mind not theoretically, it is just the nature of the beast. Well, I agree with this :) was just trying to clarify the point of the thread, within the OPs particular scope of interest. Nevermind :) So your experiments showed that you couldn't detect a perceptible difference between "if (_someBoolean)" and "if (_someBoolean > 0)" ? That would have been my guess too seeing as the ArmA engine has a lot of variable incidental stuff going on too (incidental anims, environmental stuff etc) but several tests over several thousand iterations might show some overall average tendancy :) Share this post Link to post Share on other sites
killzone_kid 1330 Posted May 30, 2013 Well, I agree with this :) was just trying to clarify the point of the thread, within the OPs particular scope of interest. Nevermind :)So your experiments showed that you couldn't detect a perceptible difference between "if (_someBoolean)" and "if (_someBoolean > 0)" ? That would have been my guess too seeing as the ArmA engine has a lot of variable incidental stuff going on too (incidental anims, environmental stuff etc) but several tests over several thousand iterations might show some overall average tendancy :) Tested on 100000 iteration loop and something like 0 > 0 was pretty fast, sometimes fraction faster than true. All I can say for sure that >= or <= is slower than > or < because it has to do 2 comparisons, and this shows on test. Share this post Link to post Share on other sites
LoonyWarrior 10 Posted May 30, 2013 (edited) Maybe english isn't your first language and that is the communication problem. Have fun... LOL LOL LOL Let me explain it another way. if (scoreLimit > 0) then { limitScore = true; }; if (timeLimit > 0) then { limitTime = true; }; [color=#ff0000]// Everything above this line only runs once in this script. And you set limitScore & limitTime based on the if statements above. This only happens once.[/color] while { true } { if (limitScore) then [color=#ff0000]// Next you are checking the above variable and if its true then you do stuff. But this is in a loop, and it will keep running over and over. There is no reason to spend this proc power on this unless limitScore will be changing. And // if its going to be changing then your test is moot because at some point your going to have to evaluate limitScore so you can just do it here if that is the case. [/color] { if (scoreLimit..........) then { do something.... }; }; if (limitTime) then { if (timeLimit ..........) then { do something.... }; }; sleep 1; }; when user decide to limit both score and time.... what u will do ? ....if u will stick with that u will end up with another loop... and prove me that not... so... why two loops ?u re simply ignoring what the code says.. its hard then...... so... i asked how should i do that and your answer is that i cant speak english ? ...thats soooo cheap its not about my english... its about your code reading... and SQF syntax is same for all languages... pls answer my question... look at the code... and giv me yours better variant... right now u re just runing away from the answer.... (perhaps u already know that u re wrong all the time ?) ---------- Post added at 11:37 ---------- Previous post was at 11:29 ---------- i have this specific code... limitScore = false; limitTime = true; while { true } { if (limitScore) then { if (scoreLimit <= scoreSide...) then { do something.... }; }; if (limitTime) then { if (timeLimit <= timeLeft) then { do something.... }; }; }; and u say... hey thats bullshit since u know that limitScore will never change in the loop ok so i will end up with limitScore = false; limitTime = true; if (limitTime) then { while { true } { if (timeLimit <= timeLeft) then { do something.... }; }; }; how i will monitor the score now u idi*t ? ...with another loop ? so again.... why two loops ? YOUR SOLUTION limitScore = false; limitTime = true; if (limitScore) then { while { true } { if (timeLimit <= timeLeft) then { do something.... }; }; }; if (limitTime) then { while { true } { if (timeLimit <= timeLeft) then { do something.... }; }; }; ...why why why...... why two loops ? why its better ? ---------- Post added at 12:02 ---------- Previous post was at 11:37 ---------- Tested on 100000 iteration loop and something like 0 > 0 was pretty fast, sometimes fraction faster than true. All I can say for sure that >= or <= is slower than > or < because it has to do 2 comparisons, and this shows on test. dont bite me... :) but should compare 0 > 0 and false not true.. ...another "clue" is that boolean can be used without brackets Edited May 30, 2013 by LoonyWarrior Share this post Link to post Share on other sites
killzone_kid 1330 Posted May 30, 2013 dont bite me... :) but should compare 0 > 0 and false not true.. ...another "clue" is that boolean can be used without brackets I suggest you stop right here before you dig even bigger hole than the one you are already in. I don't want to start splitting hairs with you so rest assured will be ignoring your next question if you ever ask one in the future Share this post Link to post Share on other sites
LoonyWarrior 10 Posted May 30, 2013 (edited) I suggest you stop right here before you dig even bigger hole than the one you are already in. I don't want to start splitting hairs with you so rest assured will be ignoring your next question if you ever ask one in the future = "you shouldnt defend yourself" why ? almost all insults from my side was copy pasted his own insults... im not the bad person in this case... dont bite me... :) but should compare 0 > 0 and false not true.....another "clue" is that boolean can be used without brackets i thought that this was constructive comment... if u feel that i tryed to insult YOU in any way, im sorry for that... that wasnt my intention.. whole "fight" is very very simple... i made my code: limitScore = false; limitTime = false; if (scoreLimit > 0) then { limitScore = true; }; if (timeLimit > 0) then { limitTime = true; }; while { true } { if (limitScore) then { if (scoreLimit..........) then { do something.... }; }; if (limitTime) then { if (timeLimit ..........) then { do something.... }; }; sleep 1; }; but he contends that this is better: limitScore = false; limitTime = true; if (limitScore) then { while { true } { if (timeLimit <= timeLeft) then { do something.... }; }; }; if (limitTime) then { while { true } { if (timeLimit <= timeLeft) then { do something.... }; }; }; and when i ask why ? and im getting no response why am i bad person ? Edited May 30, 2013 by LoonyWarrior Share this post Link to post Share on other sites
jamie721 10 Posted May 30, 2013 It all dippends on weather the scripts get compiled and what sort of optimisation happen at that point. lets start here if(true) - will be fast no comparison needed no other variable to lookup the value of. as it will always be true chances are in a well optimised and compiler it will remove this statement as it does nothing. if(0>0) - will be a little slower fraction of a second if compile does not optimise. as it has to compare two values. in a well optimised compiled language it would probably evaluate at compile time and wack a true or false value in it and either remove the code check and the code within or remove the if statement depending on weather its true or false. if(myVar > 0) - this in theory will be the slowest still fraction of a second bust slower none the less as myVar could have changed so it has to retrieve what myVal evaluates to then compare it to the other value. Not a lot of optimisation can happen here as it could in theory myVal could always be different. In the age of such fast computers micro optimizations like this are not normally important when writing code but its always a good idea to keep the info in the back of you mind. Hope this clears it up for you. :D Share this post Link to post Share on other sites
Deadfast 43 Posted May 30, 2013 (edited) Firstly, let's all keep the emotions at bay, shall we? Secondly, i made my code: limitScore = false; limitTime = false; if (scoreLimit > 0) then { limitScore = true; }; if (timeLimit > 0) then { limitTime = true; }; while { true } { if (limitScore) then { if (scoreLimit..........) then { do something.... }; }; if (limitTime) then { if (timeLimit ..........) then { do something.... }; }; sleep 1; }; but he contends that this is better: limitScore = false; limitTime = true; if (limitScore) then { while { true } { if (timeLimit <= timeLeft) then { do something.... }; }; }; if (limitTime) then { while { true } { if (timeLimit <= timeLeft) then { do something.... }; }; }; Those two pieces of code may or may not be do the same thing. Can you have both time and score limited at the same time? If so, code #2 won't work correctly. It will go into the time check loop and will remain stuck there forever, never getting to check score. If not, code #2 will be more efficient - you only have to check one if condition rather than two, plus if neither score nor time is limited the loop won't run at all. You should also put the top-level if into an else. Edited May 30, 2013 by Deadfast Share this post Link to post Share on other sites
LoonyWarrior 10 Posted May 30, 2013 (edited) Firstly, let's all keep the emotions at bay, shall we?Secondly, Those two pieces of code may or may not be do the same thing. Can you have both time and score limited at the same time? If so, code #2 won't work correctly. It will go into the time check loop and will remain stuck there forever, never getting to check score. If not, code #2 will be more efficient - you only have to check one if condition rather than two, plus if neither score nor time is limited the loop won't run at all. You should also put the top-level if into an else. There is no need to put an if statement in a loop unless you need to check the statement each iteration.// There is no need for this statement, why spend the time checking this if you already know it to be true in your if statement above. The only time you need to check would be if this var would be changing. and when u wish to limit score and time for pvp mission.. and user can decide.. limit only score limit only time limit both of them when user decide to limit both of them.... no super.. to napomenuti mi smazalo rozepsanou zpravu... takze to zkratim... debata byla o necem jinem... takze z me strany jedine: muzes prosim potvrdit ze je rychlejsi IFu posilat primo boolean misto matematicke podminky ? Edited May 30, 2013 by LoonyWarrior Share this post Link to post Share on other sites