How to measure 1 second in execution ?

btw, just to add some info you might want to know.

  • timers (as well as tick components) are affected by time, dilation. if you need something precise you might want to do it differently.

that sentence is a bit ambiguous to me. but timers and ticks are virtually the same.
they will get called in the game thread, when their “delay” expires.
so if your fps is bad, you wont get a precise timer.
it will never interrupt the execution (that would be terrible), and if it did you’d have to worry about re-entrancy. in which case a component will be better, even if only to manage the timer.

a timer, and a tick interval, means:

  • it will happen in AT LEAST this amount of time. no precision or warranty.

having said that, it’s super unlikely a tick interval won’t trigger at all.

also tick interval work better with the lifetime of objects.
i had a crash because i had a recurring timer and i forgot to clear it when the object was scheduled for destruction. (before it actually gets destroyed).

I’m sorry, but i don’t think that’s how it works.
i’m not sure why you assume that it “should” to behave in certain way. ( https://www.youtube.com/watch?v=RpXyy2RLnEU )

i just checked the code. the timer manager ticks, like any other object. then tracks the time with addition. just like a component.
There’s virtually no difference between them.

the other advantage of ticks vs timer as that you can pause a tick.

the original post does not states what it tries to do, so i can’t provide a better answer.
but in terms of timer vs tick, i’m confident in what i just said.
if you need that kind of atomic precision and a frame is too much of a difference, i think you need to re-evaluate what you’re trying to achieve.
maybe you’ll have to implement your own time tracking or account for the difference.
you can implement your own time on another thread and read the platformtime, or call windows’ gettickcount (Which could be more precise than platform time, since it has the same amounts of bits, but a fixed precision, but certainly not portable and a headache).

i have hopes that your goal can be achieved with a regular timer/tick if it’s engineered properly.

1 Like