Komaqtion
You can change this now in User CP.
- Reaction score
- 469
Hello !
Ok, as you've seen I've been doing (Trying to do XD) some benchmarks on various stuff, just to see both how it works, and to get a clue on how fast different stuff are...
So, now I thought I'd do a benchmark on how much speed loss you actually recieve when using TimerUtils' substituting natives for Create/Destroy Timer, New Timer and Release Timer. (Sorry if someone has already done something like this... Haven't seen it in that case )
Comparison:
( I didn't test them one by one, but I tested them with eachother's oppisite, like [LJASS]DestroyTimer( CreateTimer() )[/LJASS] )
The tests I did was DestroyTimer( CreateTimer() ), ReleaseTimer( NewTimer() ), ReleaseTimer( CreateTimer() ) and DestroyTimer( NewTimer() ) !
Approximate Results & Conclusions:
Comments & Personal Criticism:
Code:
Ok, as you've seen I've been doing (Trying to do XD) some benchmarks on various stuff, just to see both how it works, and to get a clue on how fast different stuff are...
So, now I thought I'd do a benchmark on how much speed loss you actually recieve when using TimerUtils' substituting natives for Create/Destroy Timer, New Timer and Release Timer. (Sorry if someone has already done something like this... Haven't seen it in that case )
Comparison:
[LJASS]CreateTimer() / DestroyTimer()[/LJASS] vs [LJASS]NewTimer() / ReleaseTimer()[/LJASS]
( I didn't test them one by one, but I tested them with eachother's oppisite, like [LJASS]DestroyTimer( CreateTimer() )[/LJASS] )
The tests I did was DestroyTimer( CreateTimer() ), ReleaseTimer( NewTimer() ), ReleaseTimer( CreateTimer() ) and DestroyTimer( NewTimer() ) !
Approximate Results & Conclusions:
- Tested on Warcraft III Version 1.24c.
- [LJASS]call DestroyTimer( CreateTimer() )[/LJASS] is 814.14% (9.14138 times) faster than [LJASS]call ReleaseTimer( NewTimer() )[/LJASS].
- [LJASS]call DestroyTimer( CreateTimer() )[/LJASS] is 645.94% (7.46939 times) faster than [LJASS]call ReleaseTimer( CreateTimer() )[/LJASS].
- [LJASS]call DestroyTimer( CreateTimer() )[/LJASS] is 293.65% (3.93646 times) faster than [LJASS]call DestroyTimer( NewTimer() )[/LJASS].
- [LJASS]call DestroyTimer( NewTimer() )[/LJASS] is 132.22% (2.32223 times) faster than [LJASS]call ReleaseTimer( NewTimer() )[/LJASS].
- [LJASS]call DestroyTimer( NewTimer() )[/LJASS] is 89.75% (1.89749 times) faster than [LJASS]call ReleaseTimer( CreateTimer() )[/LJASS].
- [LJASS]call ReleaseTimer( CreateTimer() )[/LJASS] is 22.39% (1.22385 times) faster than [LJASS]call ReleaseTimer( NewTimer() )[/LJASS].
Comments & Personal Criticism:
- Note: The two last tests (ReleaseTimer( CreateTimer() ) and DestroyTimer( NewTimer() )) isn't as accurate as the others, as I only did 1000 itterations on it, because it can't overrun the 8191 size limit inside TimerUtils !
- I'm not a very experienced "Benchmarker", so please tell me if I've done something wrong here
- The first test of these in a newly started map is always a bit higher than it should be, so I didn't count them in...
Code:
JASS:
library Benchmark initializer OnInit requires TimerUtils
///////////////////////////////////////////////
// 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
endfunction
// Tests
globals
private constant string TITLE_A="Plain JASS"
//! textmacro Benchmark__TestA
call DestroyTimer( CreateTimer() )
//! endtextmacro
private constant string TITLE_B="All TU"
//! textmacro Benchmark__TestB
call ReleaseTimer( NewTimer() )
//! endtextmacro
private constant string TITLE_C="Release on regular timer"
//! textmacro Benchmark__TestC
call ReleaseTimer( CreateTimer() )
//! endtextmacro
private constant string TITLE_D="Destroy on TU timer"
//! textmacro Benchmark__TestD
call DestroyTimer( NewTimer() )
//! 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 TestC1000 takes nothing returns nothing
local integer i=10
loop
exitwhen i==0 // hence 1,000 execs
set i=i-1
// Repeat x10
//! runtextmacro Benchmark__TestC() // 1
//! runtextmacro Benchmark__TestC() // 2
//! runtextmacro Benchmark__TestC() // 3
//! runtextmacro Benchmark__TestC() // 4
//! runtextmacro Benchmark__TestC() // 5
//! runtextmacro Benchmark__TestC() // 6
//! runtextmacro Benchmark__TestC() // 7
//! runtextmacro Benchmark__TestC() // 8
//! runtextmacro Benchmark__TestC() // 9
//! runtextmacro Benchmark__TestC() // 10
endloop
endfunction
private function TestD1000 takes nothing returns nothing
local integer i=10
loop
exitwhen i==0 // hence 1,000 execs
set i=i-1
// Repeat x10
//! runtextmacro Benchmark__TestD() // 1
//! runtextmacro Benchmark__TestD() // 2
//! runtextmacro Benchmark__TestD() // 3
//! runtextmacro Benchmark__TestD() // 4
//! runtextmacro Benchmark__TestD() // 5
//! runtextmacro Benchmark__TestD() // 6
//! runtextmacro Benchmark__TestD() // 7
//! runtextmacro Benchmark__TestD() // 8
//! runtextmacro Benchmark__TestD() // 9
//! runtextmacro Benchmark__TestD() // 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.execute() // 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.execute() // x10 - 10,000 executions altogether.
exitwhen i==10
endloop
call BJDebugMsg(TITLE_B+": "+R2S(StopWatchMark(sw)*100))
set i = 0
call StopWatchDestroy(sw)
set sw=StopWatchCreate()
loop
set i=i+1
call TestC1000.execute() // x10 - 10,000 executions altogether.
exitwhen i==10
endloop
call BJDebugMsg(TITLE_C+": "+R2S(StopWatchMark(sw)*1000))
set i = 0
call StopWatchDestroy(sw)
set sw=StopWatchCreate()
loop
set i=i+1
call TestD1000.execute() // x10 - 10,000 executions altogether.
exitwhen i==10
endloop
call BJDebugMsg(TITLE_D+": "+R2S(StopWatchMark(sw)*1000))
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