From c7c94dc3c34cd17c93f8680cb37fd42ffeb6463a Mon Sep 17 00:00:00 2001 From: Thulinma <jaron@vietors.com> Date: Thu, 1 Jun 2017 20:52:15 +0200 Subject: [PATCH] Added Util::bootMS() to timing library --- lib/timing.cpp | 6 ++++++ lib/timing.h | 1 + 2 files changed, 7 insertions(+) diff --git a/lib/timing.cpp b/lib/timing.cpp index f2e02c1c..78ff8824 100644 --- a/lib/timing.cpp +++ b/lib/timing.cpp @@ -81,6 +81,12 @@ long long int Util::bootSecs() { return t.tv_sec; } +uint64_t Util::bootMS() { + struct timespec t; + clock_gettime(CLOCK_MONOTONIC, &t); + return ((uint64_t)t.tv_sec) * 1000 + t.tv_nsec / 1000000; +} + /// Gets the current time in microseconds. long long unsigned int Util::getMicros() { struct timespec t; diff --git a/lib/timing.h b/lib/timing.h index e7486806..e1d8ebab 100644 --- a/lib/timing.h +++ b/lib/timing.h @@ -9,6 +9,7 @@ namespace Util { void sleep(int ms); ///< Sleeps for roughly the indicated amount of milliseconds. long long int getMS(); ///< Gets the current time in milliseconds. long long int bootSecs(); ///< Gets the current system uptime in seconds. + uint64_t bootMS(); ///< Gets the current system uptime in milliseconds. long long unsigned int getMicros();///<Gets the current time in microseconds. long long unsigned int getMicros(long long unsigned int previous);///<Gets the time difference in microseconds. long long int getNTP();