第一种:
#include<time.h>
clock_t start, finish;
double duration;
start = clock();
//放入你想测得函数
finish = clock();
duration = (double)(finish - start) / CLOCKS_PER_SEC;
cout << "function duration is " << duration << endl;
第二种
double t = (double)getTickCount();
//放入你想测得函数
t = ((double)getTickCount() - t) / getTickFrequency();
cout << "function(seconds): " << t << endl;