How can I measure time from adb shell with milliseconds or nanoseconds resolution?
Usingdate +%.%N
from adb shell returns 1401546811.N
(seconds resolution) instead of something like 1401547289.231869798
(nanoseconds resolution).
How can I get either milliseconds or nanoseconds resolution from adb shell?
Is there some terminal program that I can use to give me this?
I am able to measure time using System.currentTimeMillis()
and System.nanoTime()
from Android application code itself, but I also need something from within adb shell
.
adb shell echo $EPOCHREALTIME
gives you the time with micro seconds, (don't write it with '\' before the variable name)mksh
(the standard Android shell since version 4.0) has a built-inEPOCHREALTIME
environment variable:So the command to get
epoch
time with microsecond accuracy in Windows would be:or in Linux:
If you just need millisecond accuracy:
Or just the milliseconds part to use with another time format:
Kind of solved my problem by using botbrew. Probably not idea, but at least it works for now.
/data/botbrew-basil/init -- date +%s.%N
-- returns nanosecond resolution.