Added Util::unixMS

This commit is contained in:
Thulinma 2020-03-12 16:23:16 +01:00
parent 5c6341a92a
commit 091926a963
2 changed files with 12 additions and 5 deletions

View file

@ -87,6 +87,12 @@ uint64_t Util::bootMS() {
return ((uint64_t)t.tv_sec) * 1000 + t.tv_nsec / 1000000; return ((uint64_t)t.tv_sec) * 1000 + t.tv_nsec / 1000000;
} }
uint64_t Util::unixMS(){
struct timeval t;
gettimeofday(&t, 0);
return ((uint64_t)t.tv_sec) * 1000 + t.tv_usec / 1000;
}
/// Gets the current time in microseconds. /// Gets the current time in microseconds.
uint64_t Util::getMicros() { uint64_t Util::getMicros() {
struct timespec t; struct timespec t;

View file

@ -11,6 +11,7 @@ namespace Util {
void sleep(int64_t ms); ///< Sleeps for roughly the indicated amount of milliseconds. void sleep(int64_t ms); ///< Sleeps for roughly the indicated amount of milliseconds.
uint64_t getMS(); ///< Gets the current time in milliseconds. uint64_t getMS(); ///< Gets the current time in milliseconds.
uint64_t bootSecs(); ///< Gets the current system uptime in seconds. uint64_t bootSecs(); ///< Gets the current system uptime in seconds.
uint64_t unixMS(); ///< Gets the current Unix time in milliseconds.
uint64_t bootMS(); ///< Gets the current system uptime in milliseconds. uint64_t bootMS(); ///< Gets the current system uptime in milliseconds.
uint64_t getMicros(); ///< Gets the current time in microseconds uint64_t getMicros(); ///< Gets the current time in microseconds
uint64_t getMicros(uint64_t previous); ///< Gets the time difference in microseconds. uint64_t getMicros(uint64_t previous); ///< Gets the time difference in microseconds.