問題
適当にループを回して出力をだした時の
処理時間を計測せよ。
答え
#include <iostream>
#include <cv.h>
#include <cxcore.h>
int main()
{
using namespace std;
const int NUM = 100;
double start,finish;
start = static_cast<double>(cvGetTickCount()) ;
for(int loop = 0; loop < NUM; ++loop)
{
cout << ( (loop * 3) % 7 ) + 2<< endl; //適当な計算
}
finish = static_cast<double>(cvGetTickCount());
double time = (finish - start) / cvGetTickFrequency();
cout << time << "マイクロ秒です\n";
cout <<"これは\n"<< time/1000000 << "秒 です\n";
return 0;
}