bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"getTicks() in ms" to add for WIN32 and Linux to commonc++?


From: Wolfgang
Subject: "getTicks() in ms" to add for WIN32 and Linux to commonc++?
Date: Fri, 2 Jan 2004 13:49:37 +0100
User-agent: KMail/1.5.4

Would it make sense to add a getTicks() type function to the CommonC++ 
framework? Or do you think it is so trivial that it does not need to be 
there? I run into this recently when porting a project from linux to win32 
using commonc++.
Here a draft for for win32 and linux.



#ifndef WIN32
#include <sys/time.h>
#else
#include <time.h>
#include <windows.h>
#endif //win32


//return number of ticks in ms
long getTicks();


ifdef WIN32
long getTicks() {
        return GetTickCount();
};
#else
long getTicks() {
        long ticks;
        struct timeval now;
        gettimeofday(&now, NULL);
        ticks = now.tv_sec * 1000l;
        ticks += now.tv_usec / 1000l;
        return ticks;
};
#endif





reply via email to

[Prev in Thread] Current Thread [Next in Thread]