how to countdown in nano second.

how to countdown in nano second. ?

i try to countdown in 1 second in my app, but i can’t found any information of the nano second reference, can anyone tell me? thanks so much.

Most timers in Corona have a millisecond resolution (1/1000th of a second).  The screen updates at a maximum rate of 1/60th of a second.  There is only one call that gives more resolution and that’s:

system.getTimer()

http://docs.coronalabs.com/api/library/system/getTimer.html

This returns the time in milliseconds since the application’s launch, but it has a fractional time to another 1/1000th, or a microsecond resolution.  I don’t know of a way to get any more precise timing.  It might be possible in native land using Corona Enterprise.  Nanoseconds would require another 1/1000th resolution beyond the microseconds…

Rob

An ARM7 clocks at a bit over 100 MIPS, tops, so there’d be little point in nanosecond resolution, as any processing you did with it on an iPhone or Android tablet would take ‘so long’ it would destroy the accuracy …

Echoing paulscottrobson, a “fast” ARM chip these days is 1.5GHz … that’s a clock cycle time of 0.66 nsec.  So you’d have 1-2 clock cycles to do anything before the timer triggered again.

Why do you feel you need nsec resolution? 

And that’s if you’re writing machine code.  A function call to just get the time at that resolution is going to take a minimum of 5 CPU instructions.  By the time you add all the overhead of your code running in Lua byte code, passing through your Objective-C interface to get to the machine code will probably be dozens of instructions which will make getting any nanosecond resolution.

Most timers in Corona have a millisecond resolution (1/1000th of a second).  The screen updates at a maximum rate of 1/60th of a second.  There is only one call that gives more resolution and that’s:

system.getTimer()

http://docs.coronalabs.com/api/library/system/getTimer.html

This returns the time in milliseconds since the application’s launch, but it has a fractional time to another 1/1000th, or a microsecond resolution.  I don’t know of a way to get any more precise timing.  It might be possible in native land using Corona Enterprise.  Nanoseconds would require another 1/1000th resolution beyond the microseconds…

Rob

An ARM7 clocks at a bit over 100 MIPS, tops, so there’d be little point in nanosecond resolution, as any processing you did with it on an iPhone or Android tablet would take ‘so long’ it would destroy the accuracy …

Echoing paulscottrobson, a “fast” ARM chip these days is 1.5GHz … that’s a clock cycle time of 0.66 nsec.  So you’d have 1-2 clock cycles to do anything before the timer triggered again.

Why do you feel you need nsec resolution? 

And that’s if you’re writing machine code.  A function call to just get the time at that resolution is going to take a minimum of 5 CPU instructions.  By the time you add all the overhead of your code running in Lua byte code, passing through your Objective-C interface to get to the machine code will probably be dozens of instructions which will make getting any nanosecond resolution.