Quick Speed Fact

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
There ARE stopwatch natives, please look around before making assumptions. :O
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Before it, I can't get work with stopwatch in 1.21b, Warcraft does not load the map, anyway.
I tried before, but the map won't load, anyway.
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Make sure to import common.j as scripts\common.j or it doesn't work.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Lol, I just had a brilliant idea.
JASS:
globals
    integer array AA
    integer IA=0
    integer array AB
    integer IB=0
endglobals
function F1 takes nothing returns nothing
    set IA=IA+1
    set AA[IA]=1
endfunction
function F2 takes nothing returns nothing
    set IB=IB+1
    set AB[1]=IB
endfunction

If F1 is slower than F2, kudos to the person who figures out why (it is mentioned in my I2C tutorial). :cool:

Can someone test it for 4100 calls of each? :p

PS.
>Make sure to import common.j as scripts\common.j or it doesn't work.
I did try that, of course. :)
But I'll try the latest version some time.
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Also, make sure you use the NewGen Warcraft.

Edit: I might've did the test wrong, but here's my results.

Ok,

F1 - .374
F2 - .334

(Values multiplied by 100000)
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Yesh, It works for me now.

Result (1000 executions):
Hashtable : 0.04
Struct array : 0.025

JASS:
globals
    integer ii = GetRandomInt(-0x10000,0x10000)
endglobals

struct Data
    integer array lol[100]
endstruct

function Trig_Test_Actions takes nothing returns nothing
    local real result = 0
    local integer sw = StopWatchCreate()
    local integer i = 0
    
    loop
    exitwhen i == 1000
        set Data(i).lol[0] = ii
        set i = i + 1
    endloop
    
    set result = result + StopWatchMark(sw)
    call BJDebugMsg(R2S(result))
    call StopWatchDestroy(sw)
endfunction


JASS:
globals
    hashtable ht = InitHashtable()
    integer ii = GetRandomInt(-0x10000,0x10000)
endglobals

function Trig_Test_Actions takes nothing returns nothing
    local real result = 0
    local integer sw = StopWatchCreate()
    local integer i = 0
    
    loop
    exitwhen i == 1000
        call SaveInteger(ht,i,0,ii)
        set i = i + 1
    endloop
    
    set result = result + StopWatchMark(sw)
    call BJDebugMsg(R2S(result))
    call StopWatchDestroy(sw)
endfunction
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
LOL

25098330.jpg


1000 executions test.

JASS:
library Classic initializer Init

    globals
        private gamecache gc
        private hashtable ht
        private integer array Data
    endglobals
    
    function StoreStruct takes handle whichHandle, integer whichStruct returns nothing
        call StoreInteger(gc,I2S(GetHandleId(whichHandle)),"0",whichStruct)
    endfunction
    
    function GetStoredStruct takes handle whichHandle returns integer
        return GetStoredInteger(gc,I2S(GetHandleId(whichHandle)),"0")
    endfunction
    
    function SaveStruct takes handle whichHandle, integer whichStruct returns nothing
        call SaveInteger(ht,GetHandleId(whichHandle),0,whichStruct)
    endfunction
    
    function LoadStruct takes handle whichHandle returns integer
        return LoadInteger(ht,GetHandleId(whichHandle),0)
    endfunction
    
    function AttachStruct takes handle whichHandle, integer whichStruct returns nothing
        set Data[GetHandleId(whichHandle)-0x10000] = whichStruct
    endfunction
    
    function GetStruct takes handle whichHandle returns integer
        return Data[GetHandleId(whichHandle)-0x10000]
    endfunction
    
    private function Init takes nothing returns nothing
        call FlushGameCache(InitGameCache("=)"))
        set gc = InitGameCache("=)")
        set ht = InitHashtable()
    endfunction
    
endlibrary


Hashing formula in ABC v5.x is faster than v6.x after testing. =)
ABC v5.1 : 0.006
ABC v6.1 : 0.008
 

Jesus4Lyf

Good Idea™
Reaction score
397
Kingking, you should think about what you're doing more.
JASS:
    loop
    exitwhen i == 1000
        set Data(i).lol[0] = ii
        set i = i + 1
    endloop

This is terrible. How do you intend to write to the array slow of struct #1000 with a 100 member array? (Actually, I should check where the multiplication comes in.)

I'm not going to defend ABC because I believe that ABC is redundant due to hashtables (except for interface whatever you like). It should inline to hashtable use instead, I guess.

You still don't know how to benchmark. 1000 executions is nothing, and your data sets are not appropriate for how the systems are designed. You're a danger to your own integrity at the moment with the benchmark natives, and you need to be careful with your trigger happiness.

Point being you're gonna need to accept criticism, keep posting code with benchmarks so that people can see what's going on. :)
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
I am a newbie on benchmark. :D.I need some learning.
Do you mind to give some education?:p
 

Jesus4Lyf

Good Idea™
Reaction score
397
With ABC you should make sure the things you attach to will not collide, because the system is made on the premise that they are most likely not to collide and it is a reasonable assumption.

You should generally run tests at least 10,000 times.

You should multiply the results by a bigger number - you should have more than one figure to judge the speed differences on (you're judging them on the final decimal place, which really amplifies the difference between them - "1.0" and "1.19" will read as a 10% difference).

Within each iteration of the loop, you should manually execute the line 10 times, not once (why everyone always does once is beyond me). The reason is that executing the "exitwhen" condition and the increment by one actually takes a small amount of processing power. You effectively divide that by 10 by running the statement 10 times.

Arrays go up to 8,191. "1000" times "100" is "100,000". Try with an array size of around 8. Also, multiply by 0 may have a different speed to multiplying by something else. Try array slot 5 or 6 or something. :)

My advice. :)
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Jesus4Lyf said:
Sounds correct to me. Anyone wanna guess why?
Is it a joke ?
It sounds pretty obvious for me, you use a constant in function 2 instead of a variable in function 1, for the index.
 

Jesus4Lyf

Good Idea™
Reaction score
397
>It sounds pretty obvious for me, you use a constant in function 2 instead of a variable in function 1, for the index.
But I set to a constant in one, and set to a variable in the other.

The actual thing is apparently JASS arrays are not 8191 when the map starts. Cohadar said they extend every so often by copying themselves out to a new, larger memory location, when higher indexes are needed (see PUI thread).

I'm yet to thoroughly test whether or not it is true, though.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
JASS:
//StopWatchCreate
//StopWatchMark
//StopWatchDestroy
library Tests initializer init

private struct Data[8]
    integer array omg [1001]
endstruct

globals
    private hashtable ht = InitHashtable()
    private timer T = CreateTimer()
    private real T0 = 0
    private real T1 = 0
endglobals

private function Actions takes nothing returns nothing
    local integer i = 0
    local real t1
    local real t0
    local integer sw = StopWatchCreate()
    
    set t0 = StopWatchMark(sw)
    loop
    exitwhen i>=1000
        set Data(1).omg<i> = i
        set Data(2).omg<i> = i
        set Data(3).omg<i> = i
        set Data(4).omg<i> = i
        set Data(5).omg<i> = i
        set Data(6).omg<i> = i
        set Data(7).omg<i> = i
        set Data(8).omg<i> = i
        set Data(1).omg<i> = i
        set Data(2).omg<i> = i
        set i = i + 1
    endloop
    set t1 = StopWatchMark(sw)
    set T0 = 100000000 * (t1-t0)
    
    call TriggerSleepAction(.0)
    
    set i = 0
    set t0 = StopWatchMark(sw)
    loop
    exitwhen i&gt;=1000
        call SaveInteger(ht,1,i,i)
        call SaveInteger(ht,2,i,i)
        call SaveInteger(ht,3,i,i)
        call SaveInteger(ht,4,i,i)
        call SaveInteger(ht,5,i,i)
        call SaveInteger(ht,6,i,i)
        call SaveInteger(ht,7,i,i)
        call SaveInteger(ht,8,i,i)
        call SaveInteger(ht,1,i,i)
        call SaveInteger(ht,2,i,i)
        set i = i + 1
    endloop
    set t1 = StopWatchMark(sw)
    set T1 = 100000000 * (t1-t0)
    
    call StopWatchDestroy(sw)
    call BJDebugMsg(&quot;Struct array speed : &quot; + R2S(T0) + &quot;  | Hashtable speed : &quot; + R2S(T1))
endfunction

private function init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterPlayerChatEvent(trig,Player(0),&quot;set&quot;,true)
    call TriggerAddAction(trig,function Actions)
endfunction

endlibrary

</i></i></i></i></i></i></i></i></i></i>


62050807.jpg

:confused:
Am I doing it wrong?:nuts:
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • 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!
  • 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

      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