Windows下获得精确计时的方法[微秒级]

#include <Windows.h> #include <stdio.h> int main() { LARGE_INTEGER start; LARGE_INTEGER end ; LARGE_INTEGER frequency; int i = 0; if (!QueryPerformanceFrequency(&frequency)) { return -1; } QueryPerformanceCounter(&start); //开始计时 for ( i = 0; i < 100000; ++i) { ;// 用循环来测试计时 } QueryPerformanceCounter(&end); //结束计时 printf("main cost:%f/n", (double)(end.QuadPart - start.QuadPart) / (double)frequency.QuadPart); //打印for循环执行时间 return 0; }

你可能感兴趣的:(windows,测试,Integer,include)