Deleted member 219079
D
Deleted member 219079
I'm all about speed, and if there is even 1% difference please tell me
My dummy has a movement type of none and pathing size of 0, could SetUnitPosition be faster for it?SetUnitPosition I would imagine being faster in some cases (nothing nearby to path with). However it is very costly if moving a unit into something as the displacement algorithm can even cause entire frames to be dropped due to execution length.
Most of the processing of most natives is the actual parsing of them in the JASS interpreter as all names involved are dynamically looked up in interpreter fashion. SetUnitPosition should take only 2 arguments (maybe 3 if they force a facing). SetUnitX/Y will be at least 4 arguments parsed and 2 natives resolved. The end is 3-4 name resolutions against 6. Actual native code executes pretty fast so for most cases performance is entirely JASS related. The obvious exception is the displacement which even simply spawning units from a building can drop frames in crowded situations but other times is not noticeable.How would SetUnitPosition ever be faster ?
Should never be your first concern, it's the first stupid mistake many people make.I'm all about speed, and if there is even 1% difference please tell me
@DSG
How would SetUnitPosition ever be faster ? It uses more processing power just to run it. If I remember correctly nes said it uses 12 bytes compared to 3 bytes from SetUnitX and 3 bytes from SetUnitY.
I mean I like to minimize the amount of native calls I make in my loops.Should never be your first concern, it's the first stupid mistake many people make.
I don't, so I'll use SetUnitX/Y, just like I've used before.In your case the correct answer is: if you need a pathing check use SetUnitPosition, if not use SetUnitX/Y.
Were these testing the function alone or with location creation and destruction? Obviously it performs a lot slower if you involve the location object creation and destruction since that has a huge resolution overhead but that was not the question give.I have benchmarked this. SetUnitPosition is half the speed of SetUnitX + SetUnitY (approx), even with nothing there.
native SetUnitPosition takes unit whichUnit, real newX, real newY returns nothing
native SetUnitX takes unit whichUnit, real newX returns nothing
native SetUnitY takes unit whichUnit, real newY returns nothing
I don't remember saying this o-o
SetUnitPosition always runs pathfinding, even if there is nothing there. SetUnitX and SetUnitY in a map with only 1 unit will run faster than SetUnitPosition. I have benchmarked this. SetUnitPosition is half the speed of SetUnitX + SetUnitY (approx), even with nothing there. With stuff there, it runs even more slowly.
As BPower said, if you need path checking, use SetUnitPosition. If not, use SetUnitX + SetUnitY.