| 03-19-2008, 11:37 PM | #1 |
Hey, I have a question about the speed and computation required for an infinite loop versus a periodic timer. In my map I will have about 3 or so timers running for the entire time the map is open because of this I would like to know, is it faster to use a loop or a periodic timer? What are the drawbacks of either? Any advantages? Thanks. |
| 03-20-2008, 01:05 AM | #2 |
I'm quite certain Timers > Loops + Waits, I don't know the details however. |
| 03-20-2008, 01:08 AM | #3 |
Depends on the situation. For my spell I made, I use both. Timers to control movement and check to see if its expired, and wait loops to handle the SFX and such. Im pretty sure timers are faster, but loops have some advantages. |
| 03-20-2008, 01:18 AM | #4 |
lol there are no infinite loops in jass =) if you need instant callculations so use loops + new thread creating (if needed aka ExecuteFunc("xxx")) if you have alot of info and it must be procesed periodicaly (in someway) so use timers. it's simple ^^ |
| 03-20-2008, 01:59 AM | #5 |
I was just going to use a loop with no waits, just a few loops that never stop but have if's to control if the code inside them runs. To me it looks very similiar to a periodic except that it might be even more accurate because there is the smallest possible delay between the next check (ifs). I am not wondering however what ExcuteFunc("xxx") is used for. Does it immediately call a function or something? |
| 03-20-2008, 02:32 AM | #6 |
If you don't have any waits then there is no delay. The wc3 would just freeze a bit trying to run an infinite loop in an instant, and then it would either a)hit the thread limit, kill the loop and move on or b)if you used ExecuteFunc to create new threads, freeze completely... well, either that or the game crashes, I haven't done any recursion in a while so I don't remember the details. |
| 03-20-2008, 03:04 AM | #7 | |
Quote:
Oh... Well it's good that I just used timers before I knew anything... Thanks for the knowledge! Keep it coming! Can I have my question about "ExecuteFunc" answered? It sounds powerful and thus useful. |
| 03-20-2008, 03:18 AM | #8 |
ExecuteFunc calls a function using a string name parameter. It can call functions both above and below it in the script, unlike a normal function call which can only call functions above it. Therefore one of its main uses is in recursive functions. It also creates a new thread (thus resetting the op limit). This means it is also very slow. vJASS makes executefunc calls rarely or never needed since it has its own method for calling functions below in the script. |
| 03-20-2008, 04:21 AM | #9 |
