System Timer32

Bribe

vJass errors are legion
Reaction score
67
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
Reaction score
395
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
 

Nestharus

o-o
Reaction score
84
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
 
Reaction score
86
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
Reaction score
67
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
Reaction score
67
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
 

Nestharus

o-o
Reaction score
84
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
Reaction score
67
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.
 

Nestharus

o-o
Reaction score
84
Overhead on TriggerRegisterTimerExpireEvent is pretty bad.. remember that you have the whole if (TriggerEvaluate) then Execute structure and who knows what else.
 

Dirac

22710180
Reaction score
147
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
Reaction score
67
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.
  • Varine Varine:
    I ordered like five blocks for 15 dollars. They're just little aluminum blocks with holes drilled into them
  • Varine Varine:
    They are pretty much disposable. I have shitty nozzles though, and I don't think these were designed for how hot I've run them
  • Varine Varine:
    I tried to extract it but the thing is pretty stuck. Idk what else I can use this for
  • Varine Varine:
    I'll throw it into my scrap stuff box, I'm sure can be used for something
  • Varine Varine:
    I have spare parts for like, everything BUT that block lol. Oh well, I'll print this shit next week I guess. Hopefully it fits
  • Varine Varine:
    I see that, despite your insistence to the contrary, we are becoming a recipe website
  • Varine Varine:
    Which is unique I guess.
  • The Helper The Helper:
    Actually I was just playing with having some kind of mention of the food forum and recipes on the main page to test and see if it would engage some of those people to post something. It is just weird to get so much traffic and no engagement
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air

      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