Why is my Stopwatch.Frequency so low?

后端 未结 4 1468
温柔的废话
温柔的废话 2021-02-08 06:58
  Debug.WriteLine(\"Timer is high-resolution: {0}\", Stopwatch.IsHighResolution);
  Debug.WriteLine(\"Timer frequency: {0}\", Stopwatch.Frequency);

Res

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-08 07:26

    The frequence depends on the HAL (Hardware abstraction layer). Back in the pentium days, it was common to use the CPU tick (which was based on the CPU clock rate) so you ended up with really high frequency timers.

    With multi-processor and multi-core machines, and especially with variable rate CPUs (the CPU clock slows down for low power states) using the CPU tick as the timer becomes difficult and error prone, so the writers of the HAL seem to have chosen to use a slower, but more reliable hardware clock, like the real time clock.

提交回复
热议问题