Thursday, December 19, 2013

How to measure execution time with C++

Simple example:

#include 
#include 

using namespace std;

void main()
{
    clock_t begin = clock();

    // some code here we want to measure

    clock_t end = clock();

    double elapsedSeconds = double(end - begin) / CLOCKS_PER_SEC;

    cout << elapsedSeconds << endl;
}

No comments: