添加頭文件:#include<time>
定義時間變量:clock_t start,end;
記錄開始時間:start = clock();
記錄結束時間:end =clock();
計算運行時間:double seconds1=(double)(end - start)/CLOCKS_PER_SEC;
#include <iostream>
#include "math.h"
#include <armadillo>
#include <time.h>
#include "6aix_robot.h"
using namespace std;
int main()
{
clock_t start1,end1,start2,end2;
int i,j;
C6AxisData MZ204;
start1 = clock(); /*記錄起始時間*/
MZ204.Cal_pos_by_theta();
end1 =clock();
double seconds1=(double)(end1 - start1)/CLOCKS_PER_SEC;
cout<<"time1:"<<seconds1<<endl;
return 0;
}