System Timer32

Bribe

vJass errors are legion
I think it's worthwhile because I am working on a projectile system that requires a lot of local variables and I don't want to have to declare them for every instance, rather base it off T32's mechanics but have direct access to the static method.
 

emjlr3

Change can be a good thing
It just involves array look ups, variable setting, and a function call. Even for one instance, this is pretty fast. However, remember that that is not the only thing to consider. There is also the release() method (which is a lot faster than TimerUtils) and the create() method (which is also faster than creating a timer). Overall, for a standard timer utils kind of system, you would first have to use NewTimer() and then use SetTimerData(). On the loop, you would have to then use GetTimerData() per loop. In the end, you would also have to use ReleaseTimer(). Internally, those functions call other natives, while Timer32 simply sets variables and does array look-ups. So I'd say the difference would kick in even during the first instance.
first off, no one really cares about create or release - the real bread winner is the periodic lookup, which in a realistic sense is all we really need to compare (no need to get into the nuts and bolts of that)

IMO, one
JASS:
GetHandleId()-offset
should be faster then one loop through with an array lookup, so I cant see one instance of one spell being any faster periodically - obviously through 10 more on top of that and you have yourself a winner, considering the additional native calls and arithmetic, along with timer events

However, that is when comparing to TimerUtils. When comparing it to a standard struct stack, it also has a better means of setting and retrieving data. (there are no arithmetic operations)
simple addition cannot be very taxing, and I doubt the difference is significant compared to an array lookup, I would however like to see some numbers for that comparison

1 per loop of the timer, not 1 per instance
take a look at my example script - I had only one in there - I was aware of that coming into this discussion

All of that is good, but the bolded part is the key. All the "struct stack loops" are added to once trigger, which gets evaluated, which is the lowest overhead you can have on a function call, off memory. One timer per loop makes overhead of the timer expiring + function call, with T32 there is only one timer firing and the function calls all come from one trigger evaluate, in other words machine code loops through the loops and calls them each instead of jass code (inside the TriggerEvaluate).
I don't get this

you mean, in the instance of one spell (obviously many many spells all at once will overtax a system using a struct stack/spell), the overhead of:

JASS:
//timer expires
local integer i=1
local data d
loop
  exitwhen i>N
  set d=D<i>
  set i=i+1
endloop</i>


is greater then

JASS:
//trigger timer expires
call EvaluateTrigger(Trigger)
local thistype this=thistype(0).next
            loop
                exitwhen this==0
                call this.periodic()
                set this=this.next
            endloop
            return false


?? I fail to see how (though i didn't get your last response)

now, having said all that, in the grand scheme of things - this doesn't really matter at all, considering that 99.9% of the power required for spells isn't related to data lookup at all - so really all of this is probably, and ultimately, superfluous, IMO
 
I wouldn't say that it was superfluous at all. See the stress tests on this page to see where T32 fits into the picture -> http://www.thehelper.net/forums/showthread.php/161340-TimerQueue


Also, to understand just how quick evaluating one trigger over many can be
Code:
Frames per Second Benchmark Tests (32x per second)

Light Event by nestharus
    x1500: 2-3 (avg 3)
    x1200: 15-22 (avg 15)
Heavy Event by nestharus using Light features
    x1500: 2 (avg 2)
    x1200: 14-16 (avg 15)
Heavy Event by nestharus using Dynamic Features (like jesus4lyf's event)
    x1000: 8-10 (avg 10)
    x1200: 0-3 (avg 1)
Event by jesus4lyf
    x1000: 5-6 (avg 5)
    x1200: 0-1 (avg 1)
Also, if you notice, short variable names also make a huge difference. The only difference between this test
Heavy Event by nestharus using Dynamic Features (like jesus4lyf's event)

and this test
Event by jesus4lyf

are the variable names ;P
 
Question: Could you possibly make it so that the engine calls a static function per tick, that way instead of having to do certain tasks every instance every tick we can do it just once per tick. (For example, I need to get the x and y location of a specific unit and dont want to call GetUnitX&Y in every .periodic())
 

Bribe

vJass errors are legion
Question: Could you possibly make it so that the engine calls a static function per tick, that way instead of having to do certain tasks every instance every tick we can do it just once per tick. (For example, I need to get the x and y location of a specific unit and dont want to call GetUnitX&Y in every .periodic())
Basically what I said - add a second module which allows direct access to the static method, allowing us to have more control of what's happening.
 

Bribe

vJass errors are legion
No, that's a nonsense method. Allocating two integer arrays just to waste them.

I mean like this:

JASS:
static method periodic takes nothing returns boolean
    // Actions...
    return false
endmethod
    
implement StructTimer
 
Note that due to the way this is ordered, the stop/start method calls from the loop will end up evaluating triggers.

Furthermore, the module is written semi poorly. It would be better to have a next/prev that is global to all modules to save on spamming the global scope. If there are 8000 timers running 32x a second, then the map is already going to be unplayable.

Also, keep in mind that the cost of a method call can be very expensive if there are many locals declared within that method call. It'd be smarter to split the module into 3 modules to save on the method call.


Also, in the exitwhen statement, 0==this is faster than this==0. I'm sure I mentioned that before.


Next, if there are 0 instances left for a struct, that struct's trigger condition should be removed from the evaluated trigger. If there all structs have 0 instances, I want to say the timer should be paused, but the fact is that pausing a timer can cause serious bugs with TimerStart.

If the removed instance is part of the current evaluating trigger condition, would need to go into a stack for after the trigger evaluation. If not, the trigger condition can be removed directly.


Also, you should really support being able to remove the current expiring instance and adding a new instance.
 

Bribe

vJass errors are legion
Rather than adding/removing conditions, what would be the comparable overhead of [ljass]TriggerRegisterTimerExpireEvent[/ljass]? That way you could just enable/disable the module's trigger when it's empty.
 
Overhead on TriggerRegisterTimerExpireEvent is pretty bad.. remember that you have the whole if (TriggerEvaluate) then Execute structure and who knows what else.
 

Dirac

22710180
I modified the T32x module in my map to this, it's actually faster
JASS:

        private static method onInit takes nothing returns nothing
            if null==List then
                set List=Filter(function thistype.PeriodicLoop)
            else
                set List=Or(List,Filter(function thistype.PeriodicLoop))
            endif
        endmethod
    endmodule

JASS:

    private function OnInit takes nothing returns nothing
        call TriggerAddCondition(Trig,List)
        call TimerStart(CreateTimer(),PERIOD,true,function OnExpire)
    endfunction
@Bribe Why would you like to have more than 1 static method period on your struct? i mean it's possible, but why?
 

Bribe

vJass errors are legion
It wasn't that I didn't want to have more than 1 periodic, it was that I wanted to have the callback only called once per timeout instead of once per instance, and allow me to have access to all members.

Well CTL32 by Nestharus fixes those problems albeit with a hideous API.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    It is possible to automate it so that instead of moving to Archive if it has the Science, technology or sci tech tag that it gets archived there instead. I am considering a new Weird News Tag
  • tom_mai78101 tom_mai78101:
    Please do. I'll try to tag the news appropriately when I get the chance.
  • The Helper The Helper:
    The new Discourse forum software we are moving to next does alot with the tags and also hashtags
  • The Helper The Helper:
    OK I found the source of your burrito post stuff it is from Reddit and possibly a facebook post too but definitely reddit
  • The Helper The Helper:
    Happy Monday!
  • The Helper The Helper:
    Happy Tuesday :)
  • Blackveiled Blackveiled:
    Happy Tuesday
  • The Helper The Helper:
    Blackveiled! What is up?
  • The Helper The Helper:
    I saw XXXConan on here the other day I dont know if you remember him
  • The Helper The Helper:
    blasts from the past
  • Blackveiled Blackveiled:
    I remember him, buncha old faces
  • jonas jonas:
    He's a software engineer at a hiring platform now I think
  • The Helper The Helper:
    I wanna know if his mom is still single LOL
  • tom_mai78101 tom_mai78101:
    I need context.
    +1
  • The Helper The Helper:
    Back in the day conan was a young one and his mom was single and I used to tease him that I was going to date his mom and be his daddy - yeah sounds bad now but it was funny at the time
  • The Helper The Helper:
    his mom is my age
  • The Helper The Helper:
    i know right it was pretty funny
  • thewrongvine thewrongvine:
    its pretty funny
    +1
  • tom_mai78101 tom_mai78101:
    Thanks for the context.
    +1
  • The Helper The Helper:
    Happy Hump Day!!!
  • Blackveiled Blackveiled:
    TH old fart gotta have a beer with me one of these days
  • The Helper The Helper:
    I am down anytime Blackveiled
  • Blackveiled Blackveiled:
    count on it then cause you don't live that far from me hah
  • The Helper The Helper:
    really that is cool! I am in Houston in the 77079 area

    Staff online

    Members online

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top