c++ 测量运行时间模板

Modified on: Thu, 07 Jan 2021 17:18:46 +0800 热度: 2,050 度
#include <bits/stdc++.h>
#include <ctime>
using namespace std;

clock_t start,stop;
double duration;

int main(int argc, const char * argv[]) {
    
    start = clock();
    
        //mycode
    
    stop = clock();
    duration = ((double)(stop-start))/CLK_TCK;
    
    cout<<duration<<endl;
    
    return 0;
}

添加新评论