Added Util::bootMS() to timing library

This commit is contained in:
Thulinma 2017-06-01 20:52:15 +02:00
parent d45a89c5e6
commit c7c94dc3c3
2 changed files with 7 additions and 0 deletions

View file

@ -81,6 +81,12 @@ long long int Util::bootSecs() {
return t.tv_sec; 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. /// Gets the current time in microseconds.
long long unsigned int Util::getMicros() { long long unsigned int Util::getMicros() {
struct timespec t; struct timespec t;

View file

@ -9,6 +9,7 @@ namespace Util {
void sleep(int ms); ///< Sleeps for roughly the indicated amount of milliseconds. 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 getMS(); ///< Gets the current time in milliseconds.
long long int bootSecs(); ///< Gets the current system uptime in seconds. 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();///<Gets the current time in microseconds.
long long unsigned int getMicros(long long unsigned int previous);///<Gets the time difference in microseconds. long long unsigned int getMicros(long long unsigned int previous);///<Gets the time difference in microseconds.
long long int getNTP(); long long int getNTP();