gpt4 book ai didi

.net - 多核和线程感知 .Net 秒表?

转载 作者:行者123 更新时间:2023-12-03 22:31:55 26 4
gpt4 key购买 nike

众所周知秒表 在将在所有内核上运行的多线程异步应用程序中可能存在问题。

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 内核一致的值?

如果不可能使秒表(QueryPerformanceCounter)多核安全,那么在内核间获得良好时间戳的下一个最佳方法是什么? 日期时间.UtcNow.Ticks Environment.TickCount ?还有其他柜台吗?

我确实需要比 DateTime.UtcNow.Ticks 可以提供的更好的分辨率。 (10-15ms)

最佳答案

我自己搜索过这个特定问题的答案,我见过的最好的是 DateTime.UtcNow。似乎没有Windows暴露的高分辨率和可靠 柜台(我已经用谷歌搜索了很长时间,但仍然没有遇到任何)。

关于.net - 多核和线程感知 .Net 秒表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9283368/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com