Multicore and thread aware .Net stopwatch?

后端 未结 2 349
清歌不尽
清歌不尽 2020-12-18 21:18

As we all know the stopwatch might have issues in a multi-threaded async application that will be running on all cores.

On a multipro

相关标签:
2条回答
  • 2020-12-18 21:46

    Actually, according to the official documentation, post-Windows XP, it should be just fine to use StopWatch / QueryPerformanceCounter on multiprocessor systems. If the system does not support invariant TSC, QPC will automatically use a different timer strategy.

    Do note the comment section, though, for virtualized systems. It seems that you have to be careful in that specific case.

    0 讨论(0)
  • 2020-12-18 21:50

    I have searched for an answer to this specific problem myself and the best that I have seen is DateTime.UtcNow. It would seem that there is no Windows exposed high resolution and reliable counter (I have googled for one for ages and still haven't come across any).

    0 讨论(0)
提交回复
热议问题