Ken wrote:
Hello
In microsoft Visual c++
Is it possible to calculate the runtime of a function?
If so where do we go to activate it.
Thank you
ken
clock() is an ANSI Std function avail in Stds conforming
implementations.
Here's an example:
#include <iostream>
#include <ctime>
int main( )
{
int x = 100;
long i = 600000L;
clock_t start, finish;
double duration;
// Measure how long to do 600000 loops 100 times.
std::cout << "Time to do " << i << " empty loops "
<< x << " times is " << std::endl;
start = std::clock();
while( x--)
{
while( i--)
continue;
i = 600000L;
}
finish = std::clock();
duration = (double)(finish - start) / CLOCKS_PER_SEC;
std::cout << duration << "seconds" << std::endl;
return 0;
}
Regards,
Larry