jwallstone
New Member
- Reaction score
- 33
I'm trying to figure out how fast various ways of using hashtables are compared to globals, and wrote this simple benchmarking script. However, depending on the number of iterations in each loop, the code only reaches a certain section. As N increases, the script stops at an earlier and earlier section. Does anyone know why this is? Is there some limitation on the number of function calls allowed in a script?
I'ved attached the map for anyone who wants to try it out, but here's the code:
I'ved attached the map for anyone who wants to try it out, but here's the code:
JASS:
function testmap takes nothing returns nothing
local hashtable table = InitHashtable()
local real t1
local real t2
local integer N = 3000
local integer counter = 0
local integer i1 = StringHash("Index1")
local integer i2 = StringHash("Index2")
local unit u = CreateUnit(Player(0),039;ewsp039;,0.0,0.0,270.0)
call PolledWait(2.0)
set t1 = TimerGetElapsed(bj_gameStartedTimer)
loop
exitwhen (counter >= N)
set counter = counter + 1
endloop
set t2 = TimerGetElapsed(bj_gameStartedTimer)
call BJDebugMsg("Time1 = " + R2S(t2-t1))
set counter = 0
set t1 = TimerGetElapsed(bj_gameStartedTimer)
loop
exitwhen (counter >= N)
call SaveAgentHandle(table, i1, i2, u)
set counter = counter + 1
endloop
set t2 = TimerGetElapsed(bj_gameStartedTimer)
call BJDebugMsg("Time2 = " + R2S(t2-t1))
set counter = 0
set t1 = TimerGetElapsed(bj_gameStartedTimer)
loop
exitwhen (counter >= N)
set u = LoadUnitHandle(table, i1, i2)
set counter = counter + 1
endloop
set t2 = TimerGetElapsed(bj_gameStartedTimer)
call BJDebugMsg("Time3 = " + R2S(t2-t1))
set counter = 0
set t1 = TimerGetElapsed(bj_gameStartedTimer)
loop
exitwhen (counter >= N)
set udg_temp = u
set counter = counter + 1
endloop
set t2 = TimerGetElapsed(bj_gameStartedTimer)
call BJDebugMsg("Time4 = " + R2S(t2-t1))
set counter = 0
set t1 = TimerGetElapsed(bj_gameStartedTimer)
loop
exitwhen (counter >= N)
set u = udg_temp
set counter = counter + 1
endloop
set t2 = TimerGetElapsed(bj_gameStartedTimer)
call BJDebugMsg("Time5 = " + R2S(t2-t1))
set counter = 0
set t1 = TimerGetElapsed(bj_gameStartedTimer)
loop
exitwhen (counter >= N)
call SaveAgentHandle(table, StringHash("Index1"), StringHash("Index2"), u)
set counter = counter + 1
endloop
set t2 = TimerGetElapsed(bj_gameStartedTimer)
call BJDebugMsg("Time6 = " + R2S(t2-t1))
set counter = 0
set t1 = TimerGetElapsed(bj_gameStartedTimer)
loop
exitwhen (counter >= N)
set u = LoadUnitHandle(table, StringHash("Index1"), StringHash("Index2"))
set counter = counter + 1
endloop
set t2 = TimerGetElapsed(bj_gameStartedTimer)
call BJDebugMsg("Time7 = " + R2S(t2-t1))
set counter = 0
set t1 = TimerGetElapsed(bj_gameStartedTimer)
loop
exitwhen (counter >= N)
call SaveAgentHandle(table, GetHandleId(u), StringHash("Index2"), u)
set counter = counter + 1
endloop
set t2 = TimerGetElapsed(bj_gameStartedTimer)
call BJDebugMsg("Time8 = " + R2S(t2-t1))
set counter = 0
set t1 = TimerGetElapsed(bj_gameStartedTimer)
loop
exitwhen (counter >= N)
set u = LoadUnitHandle(table, GetHandleId(u), StringHash("Index2"))
set counter = counter + 1
endloop
set t2 = TimerGetElapsed(bj_gameStartedTimer)
call BJDebugMsg("Time9 = " + R2S(t2-t1))
endfunction