Benchmark Submission Rules

Status
Not open for further replies.

Jesus4Lyf

Good Idea™
Reaction score
397
Benchmark submission rules regarding the [Benchmark] prefix in the JASS Help forum.

How to Benchmark

Most recent benchmark natives may be found here.
Follow the instructions there on how to apply them, except for importing common.j. Instead, use the template code below.
This is all that is required for any benchmark posted in JASS Help, following the rules below.


Rules

  • Code for benchmarks must be posted in plain vJass. There is a template provided, which is recommended for use. The next points are relevant for those not using the template.
    [*]This code must be pastable into a blank WC3 map and work without any other modifications (if possible).
    [*]The benchmark must be performed upon pressing the "esc" key.
    [*]The code being benchmarked must be executed at least 10 times consecutively at a time (without loop checks).
    [*]The benchmark code must display times (in any units, to be compared by ratios since execution times will be different on different computers) for each piece of code being benchmarked, labelled with which test it is for.
    [*]Code must be readable (reasonable layout).​
  • You must use the Submission Template provided.
    [*]You must give a % comparison between the two codes.
    [*]Code A is x% faster than Code B when the difference in time of execution is x% of the execution time of Code B.
    [*]You must post comments and criticism on your tests. It is a demonstration of maturity and demonstrates an understanding of what you are doing. If there is none, post that the fluctuation of the results is low and that the test seems stable.
    [*]You must post what version of Warcraft III you have performed the test on.​
  • The thread name must state what is being compared (if appropriate).


Submission Template

[NOPARSE]Comparison:[/NOPARSE]
[NOPARSE]
[LJASS]Function A[/LJASS] vs [LJASS]Function B[/LJASS]​
[/NOPARSE]

[NOPARSE]Approximate Results & Conclusions:[/NOPARSE]
[NOPARSE]
  • [/NOPARSE]
    [NOPARSE]
  • Tested on Warcraft III Version x.xx.[/NOPARSE]
    [NOPARSE]
  • [LJASS]Function A[/LJASS] is xx.x% faster than [LJASS]Function B[/LJASS].[/NOPARSE]
    [NOPARSE]
[/NOPARSE]

[NOPARSE]Comments & Personal Criticism:[/NOPARSE]
[NOPARSE]
  • [/NOPARSE]
    [NOPARSE]
  • [/NOPARSE]
    [NOPARSE]
[/NOPARSE]

[NOPARSE]Code:[/NOPARSE]
[NOPARSE]
JASS:
// Code
[/NOPARSE]


Code Template

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
        // ...
    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="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
            //! 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
            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)
        call Init()
    endfunction
endlibrary
 
Status
Not open for further replies.
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