Как оценить время работы алгоритма на C++


#include "stdafx.h"
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;

void main()
{
setlocale(LC_ALL,"Rus");
srand(time(0));
int N=1000, i;
clock_t start,finish;
start=clock();
for (i=0; i<=N; i++)
{
cout<<i<<endl;
}
finish=clock();
cout<<(double)(finish-start)/CLOCKS_PER_SEC<<"c"<<endl;
system("pause");
}

Оценка производительности программы C++

Производительность 0.35 с.

685

Leave a Reply

Ваш адрес email не будет опубликован.