0
我想在我的代碼中計算每個函數。所以,我有C++中的計時函數:最準確的方法
func1();
func2();
func3();
目前我使用
#include <omp.h>
#include <time.h>
double start1=omp_get_wtime();
func1();
double end1=omp_get_wtime();
cout<<"\nfunc1 run time :"<<end1-start1<<endl;
double start2=omp_get_wtime();
func2();
double end2=omp_get_wtime();
cout<<"\nfunc2 run time :"<<end2-start2<<endl;
...
問:有沒有更好的,更準確的方式比我用來測量每個功能的運行時間?
計時器可能很吵,所以要做的事情(如果可能的話)是多次運行這些功能並獲得最佳結果。 –
@TomSeddon當然,我會這麼做的。 – user153465