ADAM'S WEB PRESENCE

21 July 2008

Linux Equivalent of the Windows GetTickCount() function

Filed under: Nerd Notes — adam @ 4:08 pm

GetTickCount() is a real handy function in Windows but does not exist in Linux. This code will give a similar result:

#include <sys/time.h>

unsigned GetTickCount()
{
        struct timeval tv;
        if(gettimeofday(&tv, NULL) != 0)
                return 0;

        return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
}

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment


Powered by WordPress