Runtime calculation

K

Ken

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
 
V

Victor Bazarov

Ken said:
In microsoft Visual c++
Is it possible to calculate the runtime of a function?
If so where do we go to activate it.

Please consider posting to 'microsoft.public.vc.language', which
incidentally is the newsgroup for that compiler. Here we talk
standard C++ as a _language_ only, not products or compilers.

V
 
S

Sensei

Ken said:
In microsoft Visual c++
Is it possible to calculate the runtime of a function?
If so where do we go to activate it.


????????????????

Do you mean the time spent in a function when executing it?
 
L

Larry I Smith

Ken said:
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
 
K

Ken

Victor Bazarov said:
Please consider posting to 'microsoft.public.vc.language', which
incidentally is the newsgroup for that compiler. Here we talk
standard C++ as a _language_ only, not products or compilers.

V

sorry

I posted my message to the otehr newsgroup


Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top