Windows C++ nanosecond timing?

后端 未结 4 547
星月不相逢
星月不相逢 2021-01-14 12:36

Is there a way in C++ on windows to measure time in nanoseconds?

All i can find are linux solutions.

4条回答
  •  余生分开走
    2021-01-14 12:49

    Use Windows7 and the Hardware Counter Profiling API http://msdn.microsoft.com/en-us/library/windows/desktop/dd796395(v=vs.85).aspx

    Both rdtsc and QueryPerformanceCounter/QueryPerformanceFrequency are not accurate enough because of the large overhead, interrupts and task switches.

    [EDIT]: Sorry mixed up the link for PerformanceCounter with Hardware Counters. Sorry have used it only once and this was a quick answer.

提交回复
热议问题