Why is my Stopwatch.Frequency so low?

后端 未结 4 1470
温柔的废话
温柔的废话 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:15

    The Stopwatch.Frequency value is per second, so your frequency of 2,597,705 means you have more than 2.5 million ticks per second. Exactly how much precision do you need?

    As for the variations in frequency, that is a hardware-dependent thing. Some of the most common hardware differences are the number of cores, the frequency of each core, the current power state of your cpu (or cores), whether you have enabled the OS to dynamically adjust the cpu frequency, etc. Your frequency will not always be the same, and depending on what state your cpu is in when you check it, it may be lower or higher, but generally around the same (for you, probably around 2.5 million.)

提交回复
热议问题