HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Benchmarking Help

06-30-2006, 05:20 AM#1
emjlr3
so I tried to do some one my own, cuz I decided to switch everything I got to Tables finally and start using them, so i wanted to see the speed difference

Collapse JASS:
function LHV_BM takes nothing returns nothing
    local timer t = CreateTimer()    
    local integer i = 0
    local integer j = 0
    local real r    
    
    call SetHandleReal(t,"r",5)
    
    call TimerStart(t,99999,false,null)
    loop
        exitwhen i>25
        loop
            exitwhen j>25
            set r = GetHandleReal(t,"r")
            set j = j + 1
        endloop
        set i = i + 1
        set j = 0
    endloop       
    call BJDebugMsg("LHV BM: "+R2S(TimerGetElapsed(t)))
    
    call PauseTimer(t)
    call FlushHandleLocals(t)
    call DestroyTimer(t)
endfunction

function Tables_BM takes nothing returns nothing
    local timer t = CreateTimer()
    local string s = GetAttTable(t)
    local integer i = 0
    local integer j = 0
    local real r    
    
    call SetTableReal(s,"r",5)
    
    call TimerStart(t,99999,false,null)
    loop
        exitwhen i>25
        loop
            exitwhen j>25
            set r = GetTableReal(s,"r")
            set j = j + 1
        endloop
        set i = i + 1
        set j = 0
    endloop    
    
    call BJDebugMsg("Table BM: "+R2S(TimerGetElapsed(t)))
    
    call Clearst(s,t)    
endfunction

function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
    call ExecuteFunc("Tables_BM")
    call ExecuteFunc("LHV_BM")
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_Untitled_Trigger_001, Player(0), "-blarg", true )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction

always displays .008 for both unless i raise the first loop above 100 then it never displays anything...what gives??

btw i shotened GetAttachmentTable to GetAttTable so that works
06-30-2006, 06:38 AM#2
PipeDream
Game time doesn't elapse while JASS is hogging the CPU. What you do is tight nested ExecuteFunc() loops to avoid the script execution limits and stare at a wall clock.
Collapse JASS:
function inner takes nothing returns nothing
//Benchmarked code here
endfunction
function mezzanine takes nothing returns nothing
    local integer i = 0
    loop 
        exitwhen i > 200
        call ExecuteFunc("inner")
        set i = i + 1
    endloop
endfunction
function outer takes nothing returns nothing
    local integer i = 0
    call TriggerSleepAction(0.) //To avoid stalling during initialization
    loop
        exitwhen i > 200
        call ExecuteFunc("mezzanine")
        set i = i + 1
    endloop
    call BJDebugMsg("Done")
endfunction
BTW, I will review Corpse Explosion in the morning, sorry about the delay.
06-30-2006, 11:08 AM#3
Rising_Dusk
I like Tables, but I still use Handles myself.
I mean, I use them so sparingly and far between that it really isn't a problem in-game.

But yeah, the speed difference IS there.
Tables are fun in their own right, I just wish they could be reconfigured to not need that confounded string variable in every function they're in.
It bugs me to have to look at it. :P
06-30-2006, 01:19 PM#4
emjlr3
aight so you can't use the in game timer to do anything like this, balls, ok thnx

Quote:
BTW, I will review Corpse Explosion in the morning, sorry about the delay.

no worries, im in no hurry