- Joined
- Nov 11, 2004
- Messages
- 1,986
Hey everyone, today I was testing the benchmarking of different functions. I tried H2I, Pow among others. Something that left me shocked was when I benchmarked Sine vs DoNothing. Vexorian had proved that natives are a lot more faster than jass functions by comparing DoNothing with Cosine. I tried doing that test once more, but with sine, and the result was that DoNothing > Sine. Here's the code:
The results were: 0.006597519 seconds for DoNothing
0.007065160 seconds for Sine.
The thing is that Vexorian proved Cosine to be 3 times faster than DoNothing alone, but now I ask myself which mistake I made or if my test is right.
I also did another test.
in this one Sine > Useless. The reasons may be 2: first Useless now takes an argument, which slows it down, and second, Useless is away from the top, thus it's slower than the rest.
Results
Useless: 0.0085
Sine: 0.0073
JASS:
function Trig_Benchmark_Actions takes nothing returns nothing
local integer i = 0
local real r
local real g
//local player p = Player(0)
//local integer f = H2I(p)
local integer s = StopWatchCreate()
loop
exitwhen i >= 5000
call DoNothing()
set i = i + 1
endloop
set g = StopWatchMark(s)
set i = 0
call StopWatchDestroy(s)
set s = StopWatchCreate()
loop
exitwhen i >= 5000
call Sin(2.) //i'm not assigning it to any value, in order for it to be faster
set i = i + 1
endloop
set r = StopWatchMark(s)
call StopWatchDestroy(s)
//call BJDebugMsg(R2S(g))
call BJDebugMsg(R2SW(g,10,10))
call BJDebugMsg(R2SW(r,10,10))
endfunction
//===========================================================================
function InitTrig_Benchmark takes nothing returns nothing
set gg_trg_Benchmark = CreateTrigger( )
call TriggerAddAction( gg_trg_Benchmark, function Trig_Benchmark_Actions )
endfunction
The results were: 0.006597519 seconds for DoNothing
0.007065160 seconds for Sine.
The thing is that Vexorian proved Cosine to be 3 times faster than DoNothing alone, but now I ask myself which mistake I made or if my test is right.
I also did another test.
JASS:
function Useless takes real r returns nothing
endfunction
function Trig_Benchmark_Actions takes nothing returns nothing
local integer i = 0
local real r
local real g
//local player p = Player(0)
//local integer f = H2I(p)
local integer s = StopWatchCreate()
loop
exitwhen i >= 5000
call Useless(2.)
set i = i + 1
endloop
set g = StopWatchMark(s)
set i = 0
call StopWatchDestroy(s)
set s = StopWatchCreate()
loop
exitwhen i >= 5000
call Sin(2.)
set i = i + 1
endloop
set r = StopWatchMark(s)
call StopWatchDestroy(s)
//call BJDebugMsg(R2S(g))
call BJDebugMsg(R2SW(g,10,10))
call BJDebugMsg(R2SW(r,10,10))
endfunction
//===========================================================================
function InitTrig_Benchmark takes nothing returns nothing
set gg_trg_Benchmark = CreateTrigger( )
call TriggerAddAction( gg_trg_Benchmark, function Trig_Benchmark_Actions )
endfunction
in this one Sine > Useless. The reasons may be 2: first Useless now takes an argument, which slows it down, and second, Useless is away from the top, thus it's slower than the rest.
Results
Useless: 0.0085
Sine: 0.0073