c++ - 一秒钟有多少滴答声?

标签 c++ operating-system clock msdn performancecounter

我正在使用 KeQueryPerformanceCounter获取每秒的滴答数。

我知道这是性能计数器频率,以每秒滴答数计。我不知道如何将其转换为时间单位(比如说秒、毫秒或纳秒……任何东西)?

一秒钟有多少滴答声?什么是转换系数?

LARGE_INTEGER freq;
KeQueryPerformanceCounter(&freq);

最佳答案

在链接中:

Remarks

KeQueryPerformanceCounter always returns a 64-bit integer that represents the current value of a monotonically nondecreasing counter. The counter starts incrementing from zero when the computer starts up.

To get the resolution of the timer used to accumulate the current tick count, specify a non-NULL pointer value for the PerformanceFrequency parameter. The frequency value that the routine writes to the location pointed to by this parameter is the number of ticks per second.

在这里,这意味着 freq 变量将包含每秒的滴答数

关于c++ - 一秒钟有多少滴答声?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16769464/

相关文章:

c++ - C++ 中 main 签名的参数可以有 unsigned 和 const 限定符吗?

C++类,面向对象编程

android - 如何在Android/iOS上通过不同的线程同时读写一个文件?

assembly - 如何使用 rdtsc 在 Qemu i386 系统中进行基准测试

posix - 改变系统时间对休眠线程有什么影响?

c++ - 返回相同值的两个 Arduino 类实例

c++ - 在使用声明引入的折叠表达式中使用运算符是否合法?

c - sync() 最多需要多少时间?

c - 什么代码是用户模式代码,什么代码是内核模式代码?

linux-kernel - Linux 时钟架构