Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

time of a loop in c++

#include <iostream>
#include <time.h>
using namespace std;

int main()
{
    int finish = 20;
    int start = 1;
    int result = 0;

    double msecs;
    clock_t init, end;

    init = clock();

    for (int i = start; i <= finish; i++)
    {
        result += i;
    }


    end = clock();

    cout << ((float)(end - init)) *1000 / (CLOCKS_PER_SEC);

    system ("PAUSE");

    return 0;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #time #loop
ADD COMMENT
Topic
Name
5+1 =