How can I measure time with microsecond precision in Java?

前端 未结 12 900
死守一世寂寞
死守一世寂寞 2020-12-03 01:15

I saw on the Internet that I was supposed to use System.nanoTime() but that doesn\'t work for me - it gives me the time with milliseconds precision. I just need

12条回答
  •  隐瞒了意图╮
    2020-12-03 02:00

    If you want a reliable result, use a profiler. I suggest VisualVM, which is easy to install and is bundled with the JDK starting from version 1.6.0_07.

    It is an easy to use visual tool that integrates several commandline JDK tools and lightweight profiling capabilities.

提交回复
热议问题