1G数据在入门双核中运行
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
using namespace std;
#define SIZE 1024 * 1024 * 1024
int main()
{
LARGE_INTEGER start;
LARGE_INTEGER end;
LARGE_INTEGER freq;
QueryPerformanceFrequency(&freq);
vector<int> vec(SIZE/sizeof(int));
srand( time(NULL) );
for (int i = 0; i < vec.size(); ++i)
vec[i] = rand();
printf("sorting %d elements\n", vec.size());
QueryPerformanceCounter(&start);
sort(vec.begin(), vec.end());
QueryPerformanceCounter(&end);
printf("user time : %.10f seconds\n", (double)(end.QuadPart - start.QuadPart) / (double)freq.QuadPart);
return 0;
}
CPU T2450 2.0GHZ , 内存2G,直接运行了15分半钟,吊丝的电脑伤不起啊。。。
make it simple, make it happen