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
Staff member
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:
    You would probably have to take a loan to get the Rice cert it is like 14l
  • The Helper The Helper:
    I was hoping you were going to say you wanted to be a cook and wished to open up a Food Truck there are so many opportunities for that here
  • The Helper The Helper:
    you can only open the bar if you sell food and a food truck in the parking lot counts
  • The Helper The Helper:
    here in houston
  • The Helper The Helper:
    most bars are struggling to build food prep and even some I know are doing there own food trucks
  • The Helper The Helper:
    but yeah man you should come to Houston there is so much more opportunity here than San Antonio. Just look at all the homeless people on the Riverwalk and downtown there you cannot even walk down the street without getting mobbed them
  • The Helper The Helper:
    check out this place apparently it is the best roommate site out there roommates.com lol
  • Varine Varine:
    The homeless people reminded me of New York
  • Varine Varine:
    I'll check it out, my lease expires in like a few months so I need to figure something out.
  • Varine Varine:
    I tried to open a food truck in Sandpoint a few years ago but the city said no, then like two years later they passed new laws to encourage it and gave them all fucking tax breaks and shit. And at that point I didn't have enough money to go buy one so I was way too late to the game once other cities realized they could just bring their existing truck there, or sell their brick and mortar.
  • Varine Varine:
    I do like food trucks though, they're way more fun than restaurants and usually I also get some of that tip money there.
  • Varine Varine:
    Restaurants are really hard if you don't have a back up source of income to fund them sometimes, in my experience most owners either got really really lucky, had existing money that allowed them to buy an already successful one, or they have family money to fall back on for loans. It's few and far between to see very inspiring success stories where the person actually got it through hard work and perseverance. I thought about opening one lots and I always just end up not thinking it'll work. I would much rather just find someone that has that money and go work for them
  • The Helper The Helper:
    i am not talking about opening a brick and mortar I am talking about food trucks though I have seen some brick and mortar mexican places open up during covid that are doing good because there food is awesome!
  • The Helper The Helper:
    Food trucks are killing out here because Bars cannot open unless they sell food and the governor ok'd the use of a food truck in front as serving food
  • The Helper The Helper:
    Just not enough food trucks
  • The Helper The Helper:
    a buddy of mine just opened up a food truck and he is killing it but he is a great cook and has awesome food right in the middle of the pandemic too food trucks are immune to pandemic because they are take out in Texas you will always be able to get take out or delivery
  • The Helper The Helper:
    He is in the different food facebook groups in houston and posts videos of him making his food
  • The Helper The Helper:
    he is killing it
  • jonas jonas:
    @Varine with the restaurants, there surely is a lot of luck and hard work but most restaurants fail because they suck. Flair isn't right, economics not well thought through, food is mediocre or sucks, location is bad, etc. If you're thinking about opening one, make sure you're looking at the stories of those that would be playing at your level, don't let your hopes be dragged down by all the subpar restaurants out there.
  • jonas jonas:
    I'm a bit worried about the future of data science, there's an influx of incompetent people hired by incompetent managers, that can't last. But I'm sure smart data scientists will always be useful and hireable. Same as smart security people.
  • jonas jonas:
    My sister in law worked in a vegan food truck, the owners were also making a killing, added several trucks and opened two restaurants over 5 years
  • Ghan Ghan:
    The CompTIA stuff is pretty much crap unfortunately. The places that ask for those low-level certs aren't likely places you want to work. For IT you really want a degree, but in the meantime you need to figure out some way to learn the skills. Cybersecurity is really hot right now so competition is fierce.
  • tom_mai78101 tom_mai78101:
    I realized I don't have anything much to say, other than "Good luck!". Compared to other places, I'm just very lucky we didn't have a lot of surges of cases coming in.
  • The Helper The Helper:
    My daughter just got back from school at Georgetown TX, outside of Austin and said there were 100 cases in the last week but she also said nobody was wearing a mask anywhere so people mask up and stay safe!
    +1

    Members online

    No members online now.

    Affiliates

    Hive Workshop
    Top