8

I am trying to make a shell script to run on Android. I need to measure time at more precision than seconds - milliseconds or nanoseconds. How can I do it in Android Shell?

The date +%N does not give time in nanoseconds - it just gives N as output. I cannot find any other command/way to do it.

In Android API we can get it easily, so there must be a way to do it through shell too.

Shashank Jain
  • 847
  • 2
  • 10
  • 25

1 Answers1

0

First install busybox for android:

https://play.google.com/store/apps/details?id=stericson.busybox&hl=en

Then you can do:
adb shell "busybox date +%s"

to get the time in seconds and:
adb shell "busybox date +%N"

to get the nano seconds.

rhinoinrepose
  • 2,110
  • 2
  • 19
  • 26