多核和线程感知净秒表?多核、秒表、线程

由网友(黑魂。)分享简介:大家都知道在秒表可能将在所有内核上运行的问题在一个多线程的异步应用程序。As we all know the stopwatch might have issues in a multi-threaded async application that will be running on all cores.在多处...

大家都知道在秒表可能将在所有内核上运行的问题在一个多线程的异步应用程序。

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

在多处理器计算机,无所谓哪个处理器线程运行。因为在BIOS或硬件抽象层(HAL)的bug但是,你可以在不同的处理器不同的时序结果。要为指定线程处理器的亲和力,使用ProcessThread.ProcessorAffinity方法。

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.

有没有办法,我得到一些可靠的滴答/时间戳一样,具有很高的分辨率/精度和值是多个CPU内核一致?

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?

如果无法使秒表(QueryPerformanceCounter的)多核安全,什么是让整个内核一个很好的时间戳下一个最好的方法是什么? DateTime.UtcNow.Ticks 或 Environment.TickCount ?任何其他柜台​​?

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?

我需要比DateTime.UtcNow.Ticks可以提供更好的解决方案。 (10-15ms)

I do need better resolution than what DateTime.UtcNow.Ticks can provide. (10-15ms)

推荐答案

我寻觅的答案,这一特定问题我自己和我所见过的最好的是DateTime.UtcNow。这似乎是没有的Windows暴露高分辨率和可靠计数器(我用Google搜索的一个是年龄,还没有碰到过的话)。

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).

阅读全文

相关推荐

最新文章