As we all know the stopwatch might have issues in a multi-threaded async application that will be running on all cores.
On a multiprocessor computer, it does not matter which processor the thread runs on. However, because of bugs in the BIOS or the Hardware Abstraction Layer (HAL), you can get different timing results on different processors. To specify processor affinity for a thread, use the ProcessThread.ProcessorAffinity method.
Are there any way for me to get some reliable tick/timestamp like values that has high resolution/accuracy as well is consistent across cpu cores?
If not possible to make the stopwatch(QueryPerformanceCounter) multi-core safe, what is the next best way to get a good timestamp across cores? DateTime.UtcNow.Ticks or Environment.TickCount? Any other counters?
I do need better resolution than what DateTime.UtcNow.Ticks can provide. (10-15ms)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…