一直在想程序上是否特意让线程在指定的CPU上去运行,这样可以提高运行效率,所以特地写个代码让CPU使用率画正弦曲线的实验,我使用的是AMD X4 641的CPU,为四核四线程的片子。
代码如下
#include "stdafx.h" #include <iostream> #include <cmath> #include <ctime> #include <windows.h> using namespace std; //得到循环0xFFFFFFFF次用的秒数 unsigned int test() { unsigned int c = 0xFFFFFFFF;