Sign in to follow this  
KontosHarry

Time....

Recommended Posts

I use a function from the following book:

MUD GAME PROGRAMMING
By Ron Penton


// returns the miliseconds transcurred

// Windows gets the time since the system was started
// Linux gets the time since 1970

sint64 GetTimeMS() {
#ifdef WIN32
sint64 t;
QueryPerformanceCounter( (LARGE_INTEGER*)(&t) );
return t / g_win32counter.m_frequency;
#else
struct timeval t;
sint64 s;
gettimeofday( &t, 0 );
s = t.tv_sec;
s *= 1000;
s += (t.tv_usec / 1000);
return s;
#endif
}


And for Seconds you can use:


sint64 GetTimeS() {
return GetTimeMS() / 1000;
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this