如何计算一秒内可执行的命令行数

#include <iostream> #include <Windows.h> using namespace std; const double N = 100000000; const double SEC = 1000; int main() { LARGE_INTEGER nFrequency; ::QueryPerformanceFrequency(&nFrequency); LARGE_INTEGER nStartCounter; LARGE_INTEGER nStopCounter; ::QueryPerformanceCounter(&nStartCounter); for (int i=0; i<N; ) { ++i; } ::QueryPerformanceCounter(&nStopCounter); double nTime = 1000 * (nStopCounter.QuadPart - nStartCounter.QuadPart) / nFrequency.QuadPart; cout << N*SEC/nTime << endl; return 0; } 

 

N*SEC/nTime 348432055.74912894 double

跟我之前的测试有差距

SetThreadAffOn a multiprocessor computer, it should not matter which processor is called. However, you can get different results on different processors due to bugs in the basic input/output system (BIOS) or the hardware abstraction layer (HAL). To specify processor affinity for a thread, use the SetThreadAffinityMask function.

你可能感兴趣的:(如何计算一秒内可执行的命令行数)