Precise time measurement in Java

后端 未结 5 885
说谎
说谎 2021-02-07 07:28

Java gives access to two method to get the current time: System.nanoTime() and System.currentTimeMillis(). The first one gives a result in nanoseconds,

5条回答
  •  一个人的身影
    2021-02-07 08:00

    The problem with getting super precise time measurements is that some processors can't/don't provide such tiny increments.

    As far as I know, System.currentTimeMillis() and System.nanoTime() is the best measurement you will be able to find.

    Note that both return a long value.

提交回复
热议问题