| 09-09-2009, 08:47 AM | #1 |
You dudes ;D I just made a AoS Move System (Waypoint system). How fast is IsUnitInGroup? Is it faster to load from hashtables? I could run the IsUnitInGroup check or check if there is something saved to the unit in the hashtable. What is more save/faster? I run the condition everytime an unit on map gets an order,... |
| 09-09-2009, 12:12 PM | #2 |
IsUnitInGroup can be very slow for large groups[citation needed]. Hashtable won't be slower if there are more units. However, I don't know at how many units hastable becomes faster. |
| 09-09-2009, 12:44 PM | #3 |
If I do this: JASS:set i = LoadInteger(hashtable, GetUnitID(u), 0) will I get an error or just a null? Or even a -1? What do I get then? |
| 09-09-2009, 02:32 PM | #4 |
hashtable supersedes Table? |
| 09-09-2009, 02:34 PM | #5 |
yeah... But, back to topic, is the native IsUnitInGroup() fast or not? |
| 09-09-2009, 02:39 PM | #6 |
It's fast enough. Christ. |
| 09-09-2009, 02:41 PM | #7 |
Fast enough to not be noticeable in 200 calls per second? I must know, else I use hashtable request. The problem / or situation is: I have a hashtable and an unitgroup. Just need to check if its in one of those. |
| 09-09-2009, 02:45 PM | #8 |
I call the thing roughly that many times a second in my most recent map and my craptastic computer holds out at 40fps. I would imagine it really depends on how big your group is, mine is about 40 units large at any given time. |
| 09-09-2009, 02:47 PM | #9 |
Unitgroup can hold up to 300 units. Edit: So I should to use LoadInteger instead of using groups, right? If there is nothing found, does it return a 0 in a load, or a null in a handle load? |
| 09-09-2009, 03:49 PM | #10 |
Did anyone ever prove whether IsUnitInGroup's time grows up linearly with the addition of units? I really, really think that's not the case and that it does some hashing. IsUnitInGroup and hashtables are probably tied for all practical purposes (in speed) |
| 09-09-2009, 03:56 PM | #11 | |
Quote:
|
| 09-09-2009, 08:19 PM | #12 | |
Quote:
Linearly? No. It's O(1) up to something like 64, then increases. At some utterly insane level (thousands and thousands if I remember correctly) I think it was 50x slower or something, so I wouldn't care if you don't have ghosts accumulating. |
| 09-10-2009, 07:27 AM | #13 |
Hmm so I should use hashtables, right?^^ |
| 09-10-2009, 09:58 AM | #14 | |
Quote:
Odds are that IsUnitInGroup, assuming you RefreshGroup if/when needed, will be faster than H2I / hashtable lookup, unless you have hundreds of units. |
| 09-10-2009, 10:04 AM | #15 |
Why is it faster to check a group for units to fit as to just get the stored handleID of the unit and check the hashtable if at stored place there is anything saved? Can you please tell me that? Also, I have normally around 100-300 units in that group, so I might use hashtables. |
