Could You help me?

N

Nothingman

Hi!

I'd like to get time in miliseconds of working some algorithms. Could you
tell me if this program is OK??

#include <windows.h>
#include <iostream.h>

int main(int argc, char* argv[])
{

LONGLONG frequency, currentTime, lastTime;
double timeScale;
QueryPerformanceFrequency( (LARGE_INTEGER*) &frequency);
timeScale = (1.0/frequency)*1000.0;
QueryPerformanceCounter( (LARGE_INTEGER*) &lastTime);


some_algorithms();



QueryPerformanceCounter( (LARGE_INTEGER*) &currentTime);
double milisec = (currentTime-lastTime)*timeScale;

cout << milisec;


return 0;
}




Thank You
Nothingman
 
G

Gavin Deane

Hi!

I'd like to get time in miliseconds of working some algorithms. Could you
tell me if this program is OK??

#include <windows.h>

The above header marks your program out as being Windows-specific
rather than standard C++.
#include <iostream.h>

int main(int argc, char* argv[])
{

LONGLONG frequency, currentTime, lastTime;
double timeScale;
QueryPerformanceFrequency( (LARGE_INTEGER*) &frequency);
timeScale = (1.0/frequency)*1000.0;
QueryPerformanceCounter( (LARGE_INTEGER*) &lastTime);

some_algorithms();

QueryPerformanceCounter( (LARGE_INTEGER*) &currentTime);
double milisec = (currentTime-lastTime)*timeScale;

cout << milisec;

return 0;

}

LONGLONG, QueryPerformanceCounter and QueryPerformanceFrequency are
nothing to do with standard C++ and so are off-topic here. The people
who can help you with those will be in a Windows programming
newsgroup. Some suggestions in the FAQ:

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9

If you do want a standard C++ solution, look at what <time.h> (or
<ctime>) provides. It may suit your needs.

Gavin Deane
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top