gpt4 book ai didi

.net - 秒表真的坏了吗?

转载 作者:行者123 更新时间:2023-12-04 04:19:41 27 4
gpt4 key购买 nike

Stopwatch class的MSDN页面上,我发现了interesting article的链接,该链接对Stopwatch作了以下声明:

However there are some serious issues:

  • This can be unreliable on a PC with multiple processors. Due to a bug in
    the BIOS, Start() and Stop() must be executed on the same processor to get a correct result.

  • This is unreliable on processors that do not have a constant clock speed (most processors can reduce the clock speed to conserve energy). This is explained in detail here.



我有点困惑。我见过使用Stopwatch的 tons of examples,没有人提及此缺点。这有多严重?我应该避免使用秒表吗?

最佳答案

它没有被破坏,只是有局限性。对于大多数目的(阅读:非正式的微基准测试),StopWatch可以很好地使用,只是因为它足以进行非正式的测试。为了更正式的目的,您很可能希望滚动自己的工具代码,因为您将投入更多的精力来获得正确的结果。

关于.net - 秒表真的坏了吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2585813/

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