Measuring time to the millisecond

Hey guys,

I’m currently using a timer to add to a count that ultimately I would like to be accuracte to a thousandth of a second. Here is my code:

local function countTime(e)  
 if setGo == 1 then  
 timerCount = timerCount + 0.01  
 timerText = timerCount .. "s"  
 timerLable:setText( timerText )  
 end  
end  
  
timer.performWithDelay(10, countTime, 0)  
  

This is to test it as counting a hundredth of a second, but it seems that it doesn’t happen every 10 miliseconds?

Is there something that I’m doing wrong, or something I can do to make this as accurate as possible?

Thanks for any help.

// red. [import]uid: 7143 topic_id: 3084 reply_id: 303084[/import]

system.getTimer() --Returns time in milliseconds since application launch

Have a look on the video Gear animation #5 and the function “animate” using system.getTimer and how to define an elapse time.
At the end of the function, instead of using “Runtime: addEventListener (“enterFrame”, animate)”, try with:

timer.performWithDelay (10, countTime, 0) [import]uid: 8970 topic_id: 3084 reply_id: 9046[/import]

Thanks f2cx that works great! :slight_smile:

// red. [import]uid: 7143 topic_id: 3084 reply_id: 9216[/import]