B4A Library NanoTime

Here is the first of two support libraries for my MidiSystem Library. This is a simple NanoTime wrapper.

From the Android Docs:

Returns the current timestamp of the most precise timer available on the local system, in nanoseconds. Equivalent to Linux's CLOCK_MONOTONIC.

This timestamp should only be used to measure a duration by comparing it against another timestamp on the same device. Values returned by this method do not have a defined correspondence to wall clock times; the zero value is typically whenever the device last booted. Use currentTimeMillis() if you want to know what time it is.

Download and unzip the file and copy the .jar and .xml files to your additional libraries folder.

Edit (Erel): I've removed Utils.java from the jar file.
 

Attachments

  • NanoTime.zip
    1.1 KB · Views: 541
Last edited by a moderator:

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi

Could you give me sample to tell me how to use it ? :p

Here is the first of two support libraries for my MidiSystem Library. This is a simple NanoTime wrapper.

From the Android Docs:



Download and unzip the file and copy the .jar and .xml files to your additional libraries folder.
 

stevel05

Expert
Licensed User
Longtime User
B4X:
Dim NT As NanoTime
Log(NT.NanoTime)

How you use it depends on what you want to do with it, the value returned bears no relation to actual date/time, you can measure time passed between two calls to the timer with the most accurate clock available on your device. Example attached
 

Attachments

  • NT.zip
    7.9 KB · Views: 435

xpectmore

Member
Licensed User
Longtime User
i know is 2 years old this thread but supposing i shouldn't fill the forum with unlinked and not usefull information :
this is suppose to work like this ? i mean how "precise" are the results?
 

Attachments

  • nanotime_test.zip
    11.2 KB · Views: 354

stevel05

Expert
Licensed User
Longtime User
The accuracy will depend what else the device (not just your app) is doing while the timer is running. it is accurate enough to run a Midi sequencer without any noticeable delays.
 

xpectmore

Member
Licensed User
Longtime User
thank you so much : for your work and for the answer that conclude me i wasn't wrong with anything ,so wasn't a misuse of your library.
i was thinkin' that Android wasn't perfect so that why isn't this test fully functional and so i gain some experience with stuff work inside the system or did not ,
just to know the limits.
(ps. i don't have Java skills i don't need to learn Java ,i also do not like Java ,i programming by several languages/script languages , .exe x86/ x64 windows also =nothing c,c++ microsoft,but other better compilers such purebasic and i like b4a,even is so primary)
happy holidays ,happy new year!
 
Top