因为你用的debug版在跑。
I7 6600U 2.6GHz的CPU,数据从大到小排列,排序成从小到大:
1000000,用时16ms。
10000000,用时168ms。
数据采用rand()函数随机,排序成从小到大:
1000000,用时74ms。
10000000,用时648ms。
const int N = 1000000;
int * p = new int[N];
for (int i = N; i > 0; --i)
p[i-1] = rand(); //i
auto start_tp = std::chrono::high_resolution_clock::now();
std::sort(p, p + N);
auto dt = std::chrono::high_resolution_clock::now() - start_tp;
printf("%lldms\n", std::chrono::duration_cast<:chrono::milliseconds>(dt).count());