What is the timer precision?

I am trying to use a timer to repeat an action at very regular intervals. (To a beat of a song) but it doesn’t seem to keep the beat.

Am I doing something wrong or is it the timer that is not very precise? [import]uid: 8192 topic_id: 12492 reply_id: 312492[/import]

[lua]local score = 0

function add_score()
score = score + 1
print(score)
end

timer.performWithDelay(3000, add_score,0)[/lua]

this will add score every 3 seconds
i compared it with system clock and i think it pretty precise

try it yourself [import]uid: 16142 topic_id: 12492 reply_id: 45637[/import]

Have you tried it on the device?
[import]uid: 8192 topic_id: 12492 reply_id: 45653[/import]

i tried it on device, android
its still pretty accurate
[lua]local score = 0
local textField = display.newText("Score: ", 0, 0, native.systemFont, 50)
textField.x = 150; textField.y = 150

function add_score()
score = score + 1
print(score)
textField.text = "Score: " … score
end

timer.performWithDelay(2000, add_score,0)[/lua] [import]uid: 16142 topic_id: 12492 reply_id: 45656[/import]

I tested something timer based like this today on an iPhone4 and on an iPhone3GS - as far I could tell it was totally precise. (Obviously as a human I couldn’t likely tell if it was a few milliseconds off, of course.) [import]uid: 52491 topic_id: 12492 reply_id: 45785[/import]

I am going to do more testing this weekend. I am very perplexed about this. I have the physics engine going too maybe that’s not very accurate.

I will dig deeper to see what’s happening.
[import]uid: 8192 topic_id: 12492 reply_id: 45839[/import]

My guess:
If OTHER enterFrame events are slow, then you get a frame refresh backlog, and it might throws off the timer…

Just a hunch…try disabling all other enterFrame events and see if it gets more accurate… [import]uid: 6175 topic_id: 12492 reply_id: 45945[/import]