Timer Component Milliseconds not accurate

I'm playing around with the Vision Timer Component and I have come across an issue.

I set up one Timer to count seconds 1,000ms delay with 1,000ms initial delay. Step 1
I have another counter attempting to count 1/100 of a second. 10ms delay 10ms initial delay. Step 1

When my second counter hits 1, my other counter is only at 40. This is pretty consistent, I can get it up to 41 or down to 39 by alerting the initial delay.

If I set the delays to 100ms, the counter consistently hits 10 by the time the second hits 1.

Both get triggered at the same time by linking the 'Running' properties to the same trigger.

My goal here is to use the timers to drive a simulation that will show 1 hour pass in 1 minute. Problem is I also need to know the seconds within that 1 minute simulated hour.

Hope this makes sense.

The timer component uses the Swing foreground thread. Timing for delays are not defined as precise, but rather, "no less than". Anything that bogs down the foreground thread can perturb UI delays.

Use timestamps. (From the now() expression function or system.date.now().)

If you need more precision, use java's System.nanoTime().

4 Likes

Thank you for this explanation. For my purpose accuracy isn't really a big issue. So I am simply going to use the Timer Computer with 100ms delay and the value formatted to display like mm:ss.

My simulated 1 minute hour will be closer to a 2 minute hour but I don't think that will be an issue.