How to get ticks from QueryPerformanceCounter in C#?

后端 未结 6 1071
不知归路
不知归路 2020-12-21 01:22

I need to replace Stopwatch to avoid using getters for its properties. I am going to implement it using QueryPerformanceCounter. I only need ticks nothing e

6条回答
  •  既然无缘
    2020-12-21 02:04

    Do NOT use StopWatch for high resolution timing without testing it. It has been a few years since I have tested it, but at that time it gave the default windows time resolution. You can tell because really, really fast things will take either 0 time or 10-15 milliseconds if it is using the default windows resolution (the default resolution is actually the resolution of thread context switches, presumably the default windows clock is updated at each context switch, which is about every 10-15 milliseconds).

提交回复
热议问题