|| clock() - 函數,返回值爲double
clock()是C/C++中的計時函數,函數返回從“開啓這個程序進程”到“程序中調用clock()函數”時之間的CPU時鐘計時
單元數
|| CLOCKS_PER_SEC - 常量
CLOCKS_PER_SEC表示一秒鐘內CPU運行的時鐘週期數(時鐘計時單元)
|| 利用clock(),CLOCKS_PER_SEC 測試函數運行時間
#include<ctime>
#include<iostream>
#using namespace std;
void sort(int *arr){};
int main{
double start = clock();
sort(arr);
cout << "time: " << (clock() - start) / CLOCKS_PER_SEC <<endl;
return 0;
}