Page 1 of 2

Speed diffrence on this functions?

Posted: Sat Apr 07, 2012 1:00 am
by FaMoUs
Wouldn't this be faster

Code: Select all

call SetUnitPosition(u,x+Speed[i]*Cos(Deg2Rad(GetUnitFacing(u))), y+Speed[i]*Sin(Deg2Rad(GetUnitFacing(u))))
than calling this 3?

Code: Select all

call SetUnitX(u,x+Speed[i]*Cos(Deg2Rad(GetUnitFacing(u))))
call SetUnitY(u,y+Speed[i]*Sin(Deg2Rad(GetUnitFacing(u))))
call IssueImmediateOrder(u,"stop")
I know it looks a lot more messy but would it be faster since its only calling one function?

Re: Speed diffrence on this functions?

Posted: Sat Apr 07, 2012 8:07 am
by 3ICE
Would have to test it with a thousand units sliding.

Edit: Moved to sliding system.

Edit2: By the way 1.24d stopped SetUnitPosition from cancelling orders, so to make it fair you need call IssueImmediateOrder(u,"stop") in the first code as well.

Edit3: Also, SetUnitPosition() is worse because of its pathability checking being slow. But stopping the unit also checks pathability, so a conclusive result can only be achieved through testing.

I prefer SetUnitX and Y because they are direct control over the unit with nothing getting in the way. We can slide over cliffs, and through buildings, etc.

Edit 4: Optimized code looks messy by default :) It doesn't bother me. But again, only optimize code that is executed frequently, like over 33 times per second.

Re: Speed diffrence on this functions?

Posted: Sat Apr 07, 2012 2:27 pm
by FaMoUs
Don't actually need IssueImmediateOrder. Already test it. We on 1.26 right now so I'm guessing they re-added it.

Re: Speed diffrence on this functions?

Posted: Sat Apr 07, 2012 2:29 pm
by 3ICE
The topic I linked is closed so I can't easily let them know about your find...

Re: Speed diffrence on this functions?

Posted: Sat Apr 07, 2012 2:34 pm
by FaMoUs
Yea I saw. With SetUnitPosition it feels like the steering has improve. Might be my mind tricking me but yes hardly noticeable but i think it did.

-Edit
You Should remove call IssueImmediateOrder(u,"stop") from the first code on my first post since editing is locked in post 1.

Re: Speed diffrence on this functions?

Posted: Sat Apr 07, 2012 2:39 pm
by 3ICE
Yeah I made it do that whenever I edit someone else's post. Fix'd.

Edit: So how about that test map? I'd be interested in the result. (But not interested enough to spend a couple hours getting my mapping tools together on this laptop again. Sigh.)

Re: Speed diffrence on this functions?

Posted: Sat Apr 07, 2012 3:34 pm
by FaMoUs
Here I edit your slide system and added the 100 demon hunters. Test it. My computer can't handle 100 demon hunters sliding with out my fps dropping since I got a Pentium 4 CPU 2.93GHz with 2.50 GB of RAM.

Re: Speed diffrence on this functions?

Posted: Sat Apr 07, 2012 3:36 pm
by 3ICE
The result is not conclusive. Need two maps.

Re: Speed diffrence on this functions?

Posted: Sat Apr 07, 2012 3:40 pm
by FaMoUs
Two maps? Why? To compare to the SetUnitX with SetPosition? Well Just remove the // from the code, didn't actually remove it. Just made them into comments so you can test and resave every time you want to compare

Re: Speed diffrence on this functions?

Posted: Sat Apr 07, 2012 3:47 pm
by 3ICE
And touch the vanilla world editor? Well, okay.