How can I measure time with microsecond precision in Java?

前端 未结 12 894
死守一世寂寞
死守一世寂寞 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 01:55

    That's weird. System.nanoTime() is supposed to work. Are you using the Sun JVM?

    Can you just repeat your operation 1000 times and divide the time by 1000 to find out what you need to know?

提交回复
热议问题