What is the equivalent to System.nanoTime() in .NET?

前端 未结 7 1432
暖寄归人
暖寄归人 2021-01-07 20:22

The title is pretty much self-explanatory, I\'m killing myself over this simplicity.

Looked here, but it isn\'t much helpful.

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-07 20:38

    I think you're going to hit the hard limits of the OS if you're timing in nanoseconds. Here's a good article on the topic:

    http://www.lochan.org/2005/keith-cl/useful/win32time.html

    While Windows will happily return 100 nanosecond accuracy, the clock is only guaranteed to update once every 15.6 milliseconds or so. So effectively Windows returns the time at which those updates occurred to 100 nanosecond accuracy. For more accuracy than this you probably need to be prepared to write C or assembler and run and embedded OS.

提交回复
热议问题