- Joined
- Jun 23, 2007
- Messages
- 4,066
Now that SharpCraft is released I decided to create new StopWatch natives since the old ones only work with RtC on patch 1.24 (which nobody had).
These are very useful for testing the speed of things in JASS.
Copy StopWatch.dll to the plugins folder of SharpCraft.
These are very useful for testing the speed of things in JASS.
JASS:
native StopWatchCreate takes nothing returns integer
native StopWatchTicks takes integer id returns integer
native StopWatchMark takes integer id returns integer
native StopWatchDestroy takes integer id returns nothing
JASS:
native UnitAlive takes unit id returns boolean
function Trig_esc_Actions takes nothing returns nothing
local integer sw
local integer i = 0
local integer array ticks
local unit u = CreateUnit(Player(0), 'hfoo', 0, 0, 0)
set sw = StopWatchCreate()
loop
exitwhen i == 1000
// TEST 1
if (GetWidgetLife(u) > 0.405) then
endif
set i = i + 1
endloop
set ticks[0] = StopWatchTicks(sw)
call BJDebugMsg("GetWidgetLife took " + I2S(StopWatchMark(sw)) + " milliseconds to finish.")
call StopWatchDestroy(sw)
set sw = StopWatchCreate()
set i = 0
loop
exitwhen i == 1000
// TEST 2
if (UnitAlive(u)) then
endif
set i = i + 1
endloop
set ticks[1] = StopWatchTicks(sw)
call BJDebugMsg("UnitAlive took " + I2S(StopWatchMark(sw)) + " milliseconds to finish.")
call StopWatchDestroy(sw)
if (ticks[0] > ticks[1]) then
call BJDebugMsg("UnitAlive is faster than GetWidgetLife")
else
call BJDebugMsg("GetWidgetLife is faster than UnitAlive")
endif
endfunction
//===========================================================================
function InitTrig_esc takes nothing returns nothing
set gg_trg_esc = CreateTrigger( )
call TriggerRegisterPlayerEventEndCinematic( gg_trg_esc, Player(0) )
call TriggerAddAction( gg_trg_esc, function Trig_esc_Actions )
endfunction
Copy StopWatch.dll to the plugins folder of SharpCraft.
Attachments
Last edited: