Benchmark TimerUtils' New/Release Timer VS. Regular Create/Destroy Timer !

Komaqtion

You can change this now in User CP.
Reaction score
469
Hello ! :D

Ok, as you've seen I've been doing (Trying to do XD) some benchmarks on various stuff, just to see both how it works, and to get a clue on how fast different stuff are...

So, now I thought I'd do a benchmark on how much speed loss you actually recieve when using TimerUtils' substituting natives for Create/Destroy Timer, New Timer and Release Timer. (Sorry if someone has already done something like this... Haven't seen it in that case :()

Comparison:
[LJASS]CreateTimer() / DestroyTimer()[/LJASS] vs [LJASS]NewTimer() / ReleaseTimer()[/LJASS]​

( I didn't test them one by one, but I tested them with eachother's oppisite, like [LJASS]DestroyTimer( CreateTimer() )[/LJASS] )
The tests I did was DestroyTimer( CreateTimer() ), ReleaseTimer( NewTimer() ), ReleaseTimer( CreateTimer() ) and DestroyTimer( NewTimer() ) !


Approximate Results & Conclusions:
  • Tested on Warcraft III Version 1.24c.
  • [LJASS]call DestroyTimer( CreateTimer() )[/LJASS] is 814.14% (9.14138 times) faster than [LJASS]call ReleaseTimer( NewTimer() )[/LJASS].
  • [LJASS]call DestroyTimer( CreateTimer() )[/LJASS] is 645.94% (7.46939 times) faster than [LJASS]call ReleaseTimer( CreateTimer() )[/LJASS].
  • [LJASS]call DestroyTimer( CreateTimer() )[/LJASS] is 293.65% (3.93646 times) faster than [LJASS]call DestroyTimer( NewTimer() )[/LJASS].
  • [LJASS]call DestroyTimer( NewTimer() )[/LJASS] is 132.22% (2.32223 times) faster than [LJASS]call ReleaseTimer( NewTimer() )[/LJASS].
  • [LJASS]call DestroyTimer( NewTimer() )[/LJASS] is 89.75% (1.89749 times) faster than [LJASS]call ReleaseTimer( CreateTimer() )[/LJASS].
  • [LJASS]call ReleaseTimer( CreateTimer() )[/LJASS] is 22.39% (1.22385 times) faster than [LJASS]call ReleaseTimer( NewTimer() )[/LJASS].

Comments & Personal Criticism:
  • Note: The two last tests (ReleaseTimer( CreateTimer() ) and DestroyTimer( NewTimer() )) isn't as accurate as the others, as I only did 1000 itterations on it, because it can't overrun the 8191 size limit inside TimerUtils !
  • I'm not a very experienced "Benchmarker", so please tell me if I've done something wrong here ;)
  • The first test of these in a newly started map is always a bit higher than it should be, so I didn't count them in...

Code:
JASS:
library Benchmark initializer OnInit requires TimerUtils
    ///////////////////////////////////////////////
    // Native declarations for stopwatch natives //
    //  - Requires no modified common.j import   //
    ///////////////////////////////////////////////
    native StopWatchCreate  takes nothing returns integer
    native StopWatchMark    takes integer stopwatch returns real
    native StopWatchDestroy takes integer stopwatch returns nothing
    
    /////////////////////////
    // Benchmarking script //
    /////////////////////////
    
    // Initialisation
    globals
    endglobals
    
    private function Init takes nothing returns nothing
    endfunction
    
    // Tests
    globals
    
    private constant string TITLE_A="Plain JASS"
    
    //! textmacro Benchmark__TestA
        call DestroyTimer( CreateTimer() )
    //! endtextmacro
    
    private constant string TITLE_B="All TU"
    
    //! textmacro Benchmark__TestB
        call ReleaseTimer( NewTimer() )
    //! endtextmacro
    
    private constant string TITLE_C="Release on regular timer"
    
    //! textmacro Benchmark__TestC
        call ReleaseTimer( CreateTimer() )
    //! endtextmacro
    
    private constant string TITLE_D="Destroy on TU timer"
    
    //! textmacro Benchmark__TestD
        call DestroyTimer( NewTimer() )
    //! endtextmacro
    
    endglobals
    
    // execution
    private function TestA1000 takes nothing returns nothing
        local integer i=100 // hence 1,000 execs
        loop
            exitwhen i==0
            set i=i-1
            // Repeat x10
            //! runtextmacro Benchmark__TestA() // 1
            //! runtextmacro Benchmark__TestA() // 2
            //! runtextmacro Benchmark__TestA() // 3
            //! runtextmacro Benchmark__TestA() // 4
            //! runtextmacro Benchmark__TestA() // 5
            //! runtextmacro Benchmark__TestA() // 6
            //! runtextmacro Benchmark__TestA() // 7
            //! runtextmacro Benchmark__TestA() // 8
            //! runtextmacro Benchmark__TestA() // 9
            //! runtextmacro Benchmark__TestA() // 10
        endloop
    endfunction
    private function TestB1000 takes nothing returns nothing
        local integer i=100
        loop
            exitwhen i==0 // hence 1,000 execs
            set i=i-1
            // Repeat x10
            //! runtextmacro Benchmark__TestB() // 1
            //! runtextmacro Benchmark__TestB() // 2
            //! runtextmacro Benchmark__TestB() // 3
            //! runtextmacro Benchmark__TestB() // 4
            //! runtextmacro Benchmark__TestB() // 5
            //! runtextmacro Benchmark__TestB() // 6
            //! runtextmacro Benchmark__TestB() // 7
            //! runtextmacro Benchmark__TestB() // 8
            //! runtextmacro Benchmark__TestB() // 9
            //! runtextmacro Benchmark__TestB() // 10
        endloop
    endfunction
    
    private function TestC1000 takes nothing returns nothing
        local integer i=10
        loop
            exitwhen i==0 // hence 1,000 execs
            set i=i-1
            // Repeat x10
            //! runtextmacro Benchmark__TestC() // 1
            //! runtextmacro Benchmark__TestC() // 2
            //! runtextmacro Benchmark__TestC() // 3
            //! runtextmacro Benchmark__TestC() // 4
            //! runtextmacro Benchmark__TestC() // 5
            //! runtextmacro Benchmark__TestC() // 6
            //! runtextmacro Benchmark__TestC() // 7
            //! runtextmacro Benchmark__TestC() // 8
            //! runtextmacro Benchmark__TestC() // 9
            //! runtextmacro Benchmark__TestC() // 10
        endloop
    endfunction
    
    private function TestD1000 takes nothing returns nothing
        local integer i=10
        loop
            exitwhen i==0 // hence 1,000 execs
            set i=i-1
            // Repeat x10
            //! runtextmacro Benchmark__TestD() // 1
            //! runtextmacro Benchmark__TestD() // 2
            //! runtextmacro Benchmark__TestD() // 3
            //! runtextmacro Benchmark__TestD() // 4
            //! runtextmacro Benchmark__TestD() // 5
            //! runtextmacro Benchmark__TestD() // 6
            //! runtextmacro Benchmark__TestD() // 7
            //! runtextmacro Benchmark__TestD() // 8
            //! runtextmacro Benchmark__TestD() // 9
            //! runtextmacro Benchmark__TestD() // 10
        endloop
    endfunction
    
    private function OnEsc takes nothing returns nothing
        local integer sw
        local integer i
        
        set i=0
        set sw=StopWatchCreate()
        loop
            set i=i+1
            call TestA1000.execute() // x10 - 10,000 executions altogether.
            exitwhen i==10
        endloop
        call BJDebugMsg(TITLE_A+": "+R2S(StopWatchMark(sw)*100))
        call StopWatchDestroy(sw)
        
        set i=0
        set sw=StopWatchCreate()
        loop
            set i=i+1
            call TestB1000.execute() // x10 - 10,000 executions altogether.
            exitwhen i==10
        endloop
        call BJDebugMsg(TITLE_B+": "+R2S(StopWatchMark(sw)*100))
        
        set i = 0
        call StopWatchDestroy(sw)
        set sw=StopWatchCreate()
        loop
            set i=i+1
            call TestC1000.execute() // x10 - 10,000 executions altogether.
            exitwhen i==10
        endloop
        call BJDebugMsg(TITLE_C+": "+R2S(StopWatchMark(sw)*1000))
        
        set i = 0
        call StopWatchDestroy(sw)
        set sw=StopWatchCreate()
        loop
            set i=i+1
            call TestD1000.execute() // x10 - 10,000 executions altogether.
            exitwhen i==10
        endloop
        call BJDebugMsg(TITLE_D+": "+R2S(StopWatchMark(sw)*1000))
        call StopWatchDestroy(sw)
    endfunction
    
    ///////////////////////////////
    // Registers the OnEsc event //
    ///////////////////////////////
    private function OnInit takes nothing returns nothing
        local trigger t=CreateTrigger()
        call TriggerRegisterPlayerEvent(t,Player(0),EVENT_PLAYER_END_CINEMATIC)
        call TriggerAddAction(t,function OnEsc)
        call Init()
    endfunction
endlibrary
 

Nestharus

o-o
Reaction score
84
It's pretty obvious why that is true ... > . <

TimerUtils specializes in data attachment... it takes extra steps to do that ..

KT2 specializes in merging timers together and data attachment

T32 specializes in low period timers (100% merger)

I once wrote a timer system that did % merger based on the user, but almost pointless on large timers because the chances of a merge are so tiny.


When you do benchmarks on timers, you need to compare their run speeds (with full data retrieval etc)... not their create/destroy speeds...
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Well, of course I knew that TimerUtils would be slower than using the regular Create/Destroy Timer natives... It's just a benchmark on how much slower it is ;)

When you do benchmarks on timers, you need to compare their run speeds (with full data retrieval etc)... not their create/destroy speeds...

What do you mean ? :S
Like how fast it is to attach/retrieve data to/from the timer ?
 

grim002

New Member
Reaction score
0
Your benchmark is completely off. You aren't allowing TimerUtils to actually recycle anything. Creating and destroying handles takes FAR longer than recycling them, even with extra steps involved.

Also, this benchmark is meaningless because Create/DestroyTimer are not functions that will ever be used periodically.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
The speed of Set/Get Data in those system is only the important thing to test. :p
Anyway, congratulation to your first benchmarking.
 

Jesus4Lyf

Good Idea™
Reaction score
397
  • Tested on Warcraft III Version 1.24c.
  • [LJASS]call DestroyTimer( CreateTimer() )[/LJASS] is 814.14% (9.14138 times) faster than [LJASS]call ReleaseTimer( NewTimer() )[/LJASS].
  • [LJASS]call DestroyTimer( CreateTimer() )[/LJASS] is 645.94% (7.46939 times) faster than [LJASS]call ReleaseTimer( CreateTimer() )[/LJASS].
  • [LJASS]call DestroyTimer( CreateTimer() )[/LJASS] is 293.65% (3.93646 times) faster than [LJASS]call DestroyTimer( NewTimer() )[/LJASS].
  • [LJASS]call DestroyTimer( NewTimer() )[/LJASS] is 132.22% (2.32223 times) faster than [LJASS]call ReleaseTimer( NewTimer() )[/LJASS].
  • [LJASS]call DestroyTimer( NewTimer() )[/LJASS] is 89.75% (1.89749 times) faster than [LJASS]call ReleaseTimer( CreateTimer() )[/LJASS].
  • [LJASS]call ReleaseTimer( CreateTimer() )[/LJASS] is 22.39% (1.22385 times) faster than [LJASS]call ReleaseTimer( NewTimer() )[/LJASS].
Wtf? Just compare useful things: NewTimer vs CreateTimer, ReleaseTimer vs DestroyTimer.

If you want a real mean benchmark to add, try NewTimer, SetTimerData and ReleaseTimer vs CreateTimer, SaveInteger(GetHandleId(timer...)), PauseTimer, DestroyTimer.

>Create/DestroyTimer are not functions that will ever be used periodically.
You've never made a spell with particle emitters on a knockback or something? :D
See. :p
 

Jesus4Lyf

Good Idea™
Reaction score
397
All I can conclude is, that using natives is faster?
Not necessarily... for example, I wrote TableX once which did hashing faster than gamecache...

Actually, apparently the NewTimer/ReleaseTimer stuff should be faster, or something... but these benchmarks don't test the right stuff yet (one call at a time, not both destroy and create at once).
 

quraji

zap
Reaction score
144
Steps to fix this benchmark:
1. Use TimerUtil's functions correctly (pretty sure you're not supposed to destroy any timers it gives you..)
2. Not do this weird [ljass]DestroyTimer(CreateTimer())[/ljass] stuff. Test one function at a time.
3. Don't test the natives 10,000 times and the TimerUtils 1,000...who knows how that can affect the test. Just do 8,000 for both (you want the highest possible)
 

Komaqtion

You can change this now in User CP.
Reaction score
469
So, something like this then (I'll add Create/RemoveTimer later, with the same concept :D)

JASS:
library Benchmark initializer OnInit requires TimerUtils
    ///////////////////////////////////////////////
    // Native declarations for stopwatch natives //
    //  - Requires no modified common.j import   //
    ///////////////////////////////////////////////
    native StopWatchCreate  takes nothing returns integer
    native StopWatchMark    takes integer stopwatch returns real
    native StopWatchDestroy takes integer stopwatch returns nothing
    
    /////////////////////////
    // Benchmarking script //
    /////////////////////////
    
    // Initialisation
    globals
    endglobals
    
    private function Init takes nothing returns nothing
    endfunction
    
    // Tests
    globals
        private timer array t
        private integer i1 = 1
    
    private constant string TITLE_A=&quot;NewTimer() call&quot;
    
    //! textmacro Benchmark__TestA
        set t[i1] = NewTimer()
    //! endtextmacro
    
    private constant string TITLE_B=&quot;ReleaseTimer() call&quot;
    
    //! textmacro Benchmark__TestB
        call ReleaseTimer(t[i1])
    //! endtextmacro
    
    endglobals
    
    // execution
    private function TestA1000 takes nothing returns nothing
        local integer i=100 // hence 800 execs
        loop
            exitwhen i==0
            set i=i-1
            // Repeat x8
            //! runtextmacro Benchmark__TestA() // 1
            set i1 = i1 + 1
            //! runtextmacro Benchmark__TestA() // 2
            set i1 = i1 + 1
            //! runtextmacro Benchmark__TestA() // 3
            set i1 = i1 + 1
            //! runtextmacro Benchmark__TestA() // 4
            set i1 = i1 + 1
            //! runtextmacro Benchmark__TestA() // 5
            set i1 = i1 + 1
            //! runtextmacro Benchmark__TestA() // 6
            set i1 = i1 + 1
            //! runtextmacro Benchmark__TestA() // 7
            set i1 = i1 + 1
            //! runtextmacro Benchmark__TestA() // 8
            set i1 = i1 + 1
        endloop
    endfunction
    private function TestB1000 takes nothing returns nothing
        local integer i=100
        loop
            exitwhen i==0 // hence 800 execs
            set i=i-1
            // Repeat x8
            //! runtextmacro Benchmark__TestB() // 1
            set i1 = i1 + 1
            //! runtextmacro Benchmark__TestB() // 2
            set i1 = i1 + 1
            //! runtextmacro Benchmark__TestB() // 3
            set i1 = i1 + 1
            //! runtextmacro Benchmark__TestB() // 4
            set i1 = i1 + 1
            //! runtextmacro Benchmark__TestB() // 5
            set i1 = i1 + 1
            //! runtextmacro Benchmark__TestB() // 6
            set i1 = i1 + 1
            //! runtextmacro Benchmark__TestB() // 7
            set i1 = i1 + 1
            //! runtextmacro Benchmark__TestB() // 8
            set i1 = i1 + 1
        endloop
    endfunction
    
    private function OnEsc takes nothing returns nothing
        local integer sw
        local integer i
        
        set i=0
        set sw=StopWatchCreate()
        set i1 = 1
        loop
            set i=i+1
            call TestA1000.execute() // x10 - 8,000 executions altogether.
            exitwhen i==10
        endloop
        call BJDebugMsg(TITLE_A+&quot;: &quot;+R2S(StopWatchMark(sw)*100))
        call StopWatchDestroy(sw)
        
        set i=0
        set sw=StopWatchCreate()
        set i1 = 1
        loop
            set i=i+1
            call TestB1000.execute() // x10 - 8,000 executions altogether.
            exitwhen i==10
        endloop
        call BJDebugMsg(TITLE_B+&quot;: &quot;+R2S(StopWatchMark(sw)*100))
        call StopWatchDestroy(sw)
    endfunction
    
    ///////////////////////////////
    // Registers the OnEsc event //
    ///////////////////////////////
    private function OnInit takes nothing returns nothing
        local trigger t=CreateTrigger()
        call TriggerRegisterPlayerEvent(t,Player(0),EVENT_PLAYER_END_CINEMATIC)
        call TriggerAddAction(t,function OnEsc)
        call Init()
    endfunction
endlibrary
 

Jesus4Lyf

Good Idea™
Reaction score
397
JASS:
    // Tests
    globals
        private timer t
    
    private constant string TITLE_A=&quot;NewTimer() call&quot;
    
    //! textmacro Benchmark__TestA
        set t=NewTimer()
    //! endtextmacro
    
    private constant string TITLE_B=&quot;CreateTimer() call&quot;
    
    //! textmacro Benchmark__TestB
        set t=CreateTimer()
    //! endtextmacro
    
    endglobals

Fix'd.
For destroy/release testing, you may need to actually just call DestroyTimer(CreateTimer()) and ReleaseTimer(NewTimer()).
 

quraji

zap
Reaction score
144
Or:
JASS:
    // Initialisation
    globals
        private timer array t1 [8000]
        private timer array t2 [8000]
        private integer i1 = 0
        private integer i2 = 0
    endglobals
    
    private function Init takes nothing returns nothing
        local integer i = 0
        loop
            exitwhen (i==8000)
            set T1<i> = CreateTimer()
            set T2<i> = NewTimer()
            set i = i + 1
        endloop
    endfunction
    
    // Tests
    globals
    private constant string TITLE_A=&quot;DestroyTimer() call&quot;
    
    //! textmacro Benchmark__TestA
        call DestroyTimer(t1[i1])
        set i1 = i1 + 1
    //! endtextmacro
    
    private constant string TITLE_B=&quot;ReleaseTimer() call&quot;
    
    //! textmacro Benchmark__TestB
        call ReleaseTimer(t2[i2])
        set i2 = i2 + 1
    //! endtextmacro
    
    endglobals
</i></i>


(array access and incrementing a counter should have less impact on the test than Create/NewTimer)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top