Snippet GetPlayer

Azlier

Old World Ghost
Reaction score
461
I have no idea. I never benchmarked before.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
I also wonder what will be the result on local area network, listchecker and such kind of tools.
 

Azlier

Old World Ghost
Reaction score
461
I'm not able to benchmark. Somebody else will have to.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
I'm not really surprised, just to know, how many faster ?

Also, you use the StopWatch natives with an older worldedit.exe and NewGen Warcraft.exe ?

EDIT :

Do it for 10 000 iterations or so, 1000 would be horribly inaccurate.

And also try to change the order of the benchmarks.
First wrapper, and then the native.
 

Azlier

Old World Ghost
Reaction score
461
New, accurate data says that this is about 30% faster than the Player native.

Thanks, TriggerHappy.
JASS:
library Benchmark initializer OnInit
    ///////////////////////////////////////////////
    // Native declarations for stopwatch natives //
    //  - Requires no modified common.j import   //
    ///////////////////////////////////////////////
    native StopWatchCreate  takes nothing returns integer
    native StopWatchMark    takes integer stopwatch returns real
    native StopWatchDestroy takes integer stopwatch returns nothing
    
    /////////////////////////
    // Benchmarking script //
    /////////////////////////
    
    // Initialisation
    globals
        private unit TEMP
        private player p
        private player array PLAYER
        private integer ii = 0
    endglobals
    
    private function Init takes nothing returns nothing
        // things required to be performed once before your test
    endfunction
    
    // Tests
    globals
    private constant string TITLE_A="From Array"
    //! textmacro Benchmark__TestA
        set p = PLAYER[0]
    //! endtextmacro
    private constant string TITLE_B="Player Native"
    //! textmacro Benchmark__TestB
        set p = Player(0)
    //! endtextmacro
    endglobals
    
    // execution
    private function TestA1000 takes nothing returns nothing
        local integer i=100 // hence 1,000 execs
        loop
            exitwhen i==0
            set i=i-1
            // Repeat x10
            //! runtextmacro Benchmark__TestA() // 1
            //! runtextmacro Benchmark__TestA() // 2
            //! runtextmacro Benchmark__TestA() // 3
            //! runtextmacro Benchmark__TestA() // 4
            //! runtextmacro Benchmark__TestA() // 5
            //! runtextmacro Benchmark__TestA() // 6
            //! runtextmacro Benchmark__TestA() // 7
            //! runtextmacro Benchmark__TestA() // 8
            //! runtextmacro Benchmark__TestA() // 9
            //! runtextmacro Benchmark__TestA() // 10
        endloop
    endfunction
    private function TestB1000 takes nothing returns nothing
        local integer i=100
        loop
            exitwhen i==0 // hence 1,000 execs
            set i=i-1
            // Repeat x10
            //! runtextmacro Benchmark__TestB() // 1
            //! runtextmacro Benchmark__TestB() // 2
            //! runtextmacro Benchmark__TestB() // 3
            //! runtextmacro Benchmark__TestB() // 4
            //! runtextmacro Benchmark__TestB() // 5
            //! runtextmacro Benchmark__TestB() // 6
            //! runtextmacro Benchmark__TestB() // 7
            //! runtextmacro Benchmark__TestB() // 8
            //! runtextmacro Benchmark__TestB() // 9
            //! runtextmacro Benchmark__TestB() // 10
        endloop
    endfunction
    
    private function OnEsc takes nothing returns nothing
        local integer sw
        local integer i
        
        set i=0
        set sw=StopWatchCreate()
        loop
            set i=i+1
            set ii = 0
            call TestA1000.evaluate() // x10 - 10,000 executions altogether.
            exitwhen i==10
        endloop
        call BJDebugMsg(TITLE_A+": "+R2S(StopWatchMark(sw)*100))
        call StopWatchDestroy(sw)
        
        set i=0
        set sw=StopWatchCreate()
        loop
            set i=i+1
            set ii = 0
            call TestB1000.evaluate() // x10 - 10,000 executions altogether.
            exitwhen i==10
        endloop
        call BJDebugMsg(TITLE_B+": "+R2S(StopWatchMark(sw)*100))
        call StopWatchDestroy(sw)
    endfunction
    
    ///////////////////////////////
    // Registers the OnEsc event //
    ///////////////////////////////
    private function OnInit takes nothing returns nothing
        local trigger t=CreateTrigger()
        local integer a = 0
        loop
            exitwhen a > 12
            set PLAYER[a] = Player(a)
            set a = a + 1
        endloop
        call TriggerRegisterPlayerEvent(t,Player(0),EVENT_PLAYER_END_CINEMATIC)
        call TriggerAddAction(t,function OnEsc)
        call Init()
    endfunction
endlibrary
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Just to be sure, the result is still the same when you reverse the order of the test ?
TestB , TestA
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top