scope Benchmark initializer onInit
globals
private group TestGroup = CreateGroup()
endglobals
native UnitAlive takes unit id returns boolean
private function IsAliveFilter takes nothing returns boolean
return UnitAlive(GetFilterUnit())
endfunction
private function ActionFilter takes nothing returns boolean
local unit u = GetFilterUnit()
if UnitAlive(u) then
//actions
endif
call GroupRemoveUnit(TestGroup, u)
set u = null
return false
endfunction
private function ForGroupCallback takes nothing returns nothing
//actions
endfunction
private function Actions takes nothing returns nothing
local unit first = null
local integer sw = 0
local integer array result
set sw = StopWatchCreate()
call GroupEnumUnitsInRect(TestGroup, bj_mapInitialPlayableArea, null)
set first = FirstOfGroup(TestGroup)
loop
exitwhen first == null
if (UnitAlive(first)) then
//actions
endif
call GroupRemoveUnit(TestGroup, first)
set first = FirstOfGroup(TestGroup)
endloop
set result[0] = StopWatchTicks(sw)
call StopWatchDestroy(sw)
set sw = StopWatchCreate()
call GroupEnumUnitsInRect(TestGroup, bj_mapInitialPlayableArea, Filter(function IsAliveFilter))
call ForGroup(TestGroup, function ForGroupCallback)
set result[1] = StopWatchTicks(sw)
call StopWatchDestroy(sw)
set sw = StopWatchCreate()
call GroupEnumUnitsInRect(TestGroup, bj_mapInitialPlayableArea, Filter(function ActionFilter))
set result[2] = StopWatchTicks(sw)
call StopWatchDestroy(sw)
call ClearTextMessages()
call BJDebugMsg("FirstOfGroup: " + I2S(result[0]))
call BJDebugMsg("ForGroup: " + I2S(result[1]))
call BJDebugMsg("IsAliveFilter: " + I2S(result[2]))
endfunction
//===========================================================================
private function onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterPlayerEvent(t, Player(0), EVENT_PLAYER_END_CINEMATIC)
call TriggerAddAction(t, function Actions)
endfunction
endscope