"Benchmarking" crashes ? :S

Komaqtion

You can change this now in User CP.
Reaction score
469
Hi !

I just thought I'd try benchmarking some natives and BJ's (Just for my own sake XD), and this is what I did quickly:

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
    native UnitAlive        takes unit id returns boolean
    
    /////////////////////////
    // Benchmarking script //
    /////////////////////////
    
    // Initialisation
    globals
        private unit u
    endglobals
    
    private function Init takes nothing returns boolean
        set u = CreateUnit( Player( 0 ), 'hpea', 0.0, 0.0, bj_UNIT_FACING )
        
        //call KillUnit( u )
        
        return false
    endfunction
    
    // Tests
    globals
    private constant string TITLE_A="Test A Name"
    //! textmacro Benchmark__TestA
        // Code A
    //! endtextmacro
    private constant string TITLE_B="Test B Name"
    //! textmacro Benchmark__TestB
        // Code B
    //! 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
            call UnitAlive( u ) // 1
            call UnitAlive( u ) // 2
            call UnitAlive( u ) // 3
            call UnitAlive( u ) // 4
            call UnitAlive( u ) // 5
            call UnitAlive( u ) // 6
            call UnitAlive( u ) // 7
            call UnitAlive( u ) // 8
            call UnitAlive( u ) // 9
            call UnitAlive( u ) // 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 = StopWatchCreate()
        local integer i = 0
        
        loop
            set i = i + 1
            
            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
            
            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()
        
        call TriggerRegisterPlayerEvent( t, Player( 0 ), EVENT_PLAYER_END_CINEMATIC )
        call TriggerAddAction( t, function OnEsc )
        
        set t = CreateTrigger()
        
        call TriggerRegisterTimerEvent( t, 0.00, false )
        call TriggerAddCondition( t, Condition( function Init ) )
    endfunction
    
endlibrary


And I'd believe this should work, shouldn't it ? :S

Anyways, this is what makes my map do the classical "You-haven't-saved-before-pressing-the-"Test Map"-button !" mistake, but it actually isnt XD
(If you're not firmiliar with that "crash", then it just makes you go to the Wc3 menu when testing, instead of loading the game :()

And I know it's this code, since if I comment it out, I can run the map :S

Any ideas ? :eek:
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top