标签:style blog io ar for sp div art c
由于我要测试线性筛法的速度,用上了C/C++精确计时.此时传统的clock()方法不够用了,我们需要另一种测量的办法,即CPUTicks/CPUFreq.如何实现呢?
#include <windows.h> LARGE_INTEGER freq,start,stop; QueryPerformanceFrequency(&freq); QueryPerformanceCounter(&start); //这样便得到一个CPUTick //do some stuff.... QueryPerformanceCounter(&stop); //注意LARGE_INTEGER是一个union起32bit low,high和64bit Quad的东西 //那么 double timeused=(double)(stop.QuadPart-start.QuadPart)/(double)freq.QuadPart;
标签:style blog io ar for sp div art c
原文地址:http://www.cnblogs.com/tmzbot/p/4006165.html