Advertisement

Timing my code.

Started by January 21, 2001 05:28 AM
2 comments, last by ZubZorro 24 years ago
How would i do this? i know i could use GetTickCount(), but it will just tell me how much time used, not how much time my process actually got during the time it ran. I''m looking for something like the time thingie that i use on unix, it tells it to me nicely
Jonas Meyer Rasmussenmeyer@diku.dk
Try this function:

DWORD timeGetTime(VOID);
it requires winmm.h and winmm.lib

Basically it returns the amount of time that windows has been up and running...

so just do this:
long BeginTime = TimeGetTime();
long EndTime = 0;
long DeltaTime = 0;
// code and other crap

EndTime = TimeGetTime();
DeltaTime = EndTime - BeginTime;



Regards,
Nekosion
Regards,Nekosion
Advertisement
oh yeah... it gives millisecond accuracy.

There are more precise functions you can use, but I haven''t had to use them yet.
Regards,Nekosion
I''m a fan of the HPT functions, such as QueryHighPerformanceTimer.

i''d do the same thing, but i''d call:
  //-----------------------------------------------------------------------------------------------------------------------------inline unsigned GetTime( void )// returns current tick count (in ms) using the hpt if it exists, otherwise it just calls GetTickCount{	static LARGE_INTEGER Frequency,Time;	static bool HighPerformanceTimerExists = (QueryPerformanceFrequency( &Frequency ) != 0);	if( HighPerformanceTimerExists )	{		QueryPerformanceCounter( &Time );		return unsigned( (1000u*Time.QuadPart)/Frequency.QuadPart );	}	else		return GetTickCount( );	}  


if ur using MSVC
heh

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I have no name that you may call me. I am merely Succinct.
~Succinct Demos Online~

-(Drop me a line here n''at)-


Remember, you can''t like DOS better than win32 just cuz it''s made by m$. M$-DOS is, too.
-- Succinct(Don't listen to me)

This topic is closed to new replies.

Advertisement