San*_*aga 6 c c++ windows precision performance
我想在Windows平台上以微秒精度计算函数的性能.
现在Windows本身具有毫秒级的粒度,所以我怎样才能做到这一点.
我尝试了以下示例,但没有得到正确的结果.
LARGE_INTEGER ticksPerSecond = {0};
LARGE_INTEGER tick_1 = {0};
LARGE_INTEGER tick_2 = {0};
double uSec = 1000000;
// Get the frequency
QueryPerformanceFrequency(&ticksPerSecond);
//Calculate per uSec freq
double uFreq = ticksPerSecond.QuadPart/uSec;
// Get counter b4 start of op
QueryPerformanceCounter(&tick_1);
// The ope itself
Sleep(10);
// Get counter after opfinished
QueryPerformanceCounter(&tick_2);
// And now the op time in uSec
double diff = (tick_2.QuadPart/uFreq) - (tick_1.QuadPart/uFreq);
Run Code Online (Sandbox Code Playgroud)
(男人,我会这样回答这个答案)
| 归档时间: |
|
| 查看次数: |
1293 次 |
| 最近记录: |