Snippet GetPlayer

Azlier

Old World Ghost
Reaction score
461
I would think so, too.

I can't get benchmark natives to work. :(
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
I can't neither, because my "NewGen Warcraft.exe" crash when i try to load it.

Can we use the stopwatch custom natives with something else ?
 

Nestharus

o-o
Reaction score
84
What's sad is I had already submitted something exactly like this and it was graveyarded and never looked at it again... except that mine is better because it keeps players updated through out the game and indexes them so you can loop through all current players efficiently.

It also split up playing players and computer players so that you wouldn't have to split it up yourself..

Oh well : \. There's no justice in the world is there.
 

Azlier

Old World Ghost
Reaction score
461
>something exactly like this
Mine is one function. Yours is a bunch of functions with names that don't fit the Blizzard style.

PTN_GET_PLAYER isn't an easy change compared to just adding the Get before Player.

I also looked at the code. Lots of things I see wrong, especially the requirement of BoolexprUtils.
 

Azlier

Old World Ghost
Reaction score
461
New benchmarks are needed.

JASS:
private function Actions takes nothing returns nothing
    local integer watch1
    local integer watch2
    local integer loop1 = 5000
    local integer loop2 = 5000
    local real result1 = 0
    local real result2 = 0
    local player p
    set watch1 = StopWatchCreate()
    loop
        set p = GetPlayer(0)
        set result1 = result1 + StopWatchMark(watch1)
        exitwhen loop1 == 0
        set loop1 = loop1 - 1
    endloop
    call StopWatchDestroy(watch1)
    call TriggerSleepAction(0)
    set watch2 = StopWatchCreate()
    loop
        set p = Player(0)
        set result2 = result2 + StopWatchMark(watch2)
        exitwhen loop2 == 0
        set loop2 = loop2 - 1
    endloop
    call StopWatchDestroy(watch2)
    call BJDebugMsg("GetPlayer: " + R2S(result1 * 10))
    call BJDebugMsg("Player: " + R2S(result2 * 10))
endfunction
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Well, I found one thing through the tests, Azlier's array lookup is faster than Player() when it is lagging.
 

cleeezzz

The Undead Ranger.
Reaction score
268
-.- lol

also weird, lagging should slow the array lookup proportionally right =/
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
-.- lol

also weird, lagging should slow the array lookup proportionally right =/

This is what I originally thought, but after awhile of purposely stacking handles, GetPlayer() was about 567.432, while Player() was 1123.49.
 

Azlier

Old World Ghost
Reaction score
461
How many handles are we talking?
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
I just spammed handles using CreateUnit, special effects everywhere, and whatnot. I would say around... Alot? I didn't have a(n) *inefficient* handle counter.
 

Azlier

Old World Ghost
Reaction score
461
Use a handle counter. :p

Err. New results show that this is faster 70% of the time. How weird.
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Well I did a full re-test on an empty map and I must say, the results were unexpected. Azlier's GetPlayer returned the lowest value 7/10 times... Here's a screenie of one of them.
 

Attachments

  • Omigod~.jpg
    Omigod~.jpg
    320.7 KB · Views: 334

Azlier

Old World Ghost
Reaction score
461
1000 executions, with the results multiplied by 100.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Try to change the order of the benchmark (Player() first and then your array).
You can have the opposite result.

Also you really should use a higher value, like 10000 and a TriggerSleepAction(0) (to open a new tread) between the 2 evaluations, to be much more accurate.

PS :

I'm sure you know it, but don't forget to disable the debug mode when you save the script, or your function won't be inlined.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top