diff --git a/src/engine/helper/HL_Sync.cpp b/src/engine/helper/HL_Sync.cpp index 9344d1d3..9e4671c5 100644 --- a/src/engine/helper/HL_Sync.cpp +++ b/src/engine/helper/HL_Sync.cpp @@ -127,6 +127,13 @@ int64_t chronox::getDelta(const timespec& a, const timespec& b) return ms_a - ms_b; } +int64_t chronox::getDelta(const timeval& a, const timeval& b) +{ + int64_t diff_seconds = a.tv_sec - b.tv_sec; + int64_t diff_microseconds = a.tv_usec - b.tv_usec; + return diff_seconds * 1000 + diff_microseconds / 1000; +} + chronox::ExecutionTime::ExecutionTime() { mStart = chronox::getTimestamp(); diff --git a/src/engine/helper/HL_Sync.h b/src/engine/helper/HL_Sync.h index fbebf184..b30fc1ca 100644 --- a/src/engine/helper/HL_Sync.h +++ b/src/engine/helper/HL_Sync.h @@ -64,6 +64,7 @@ public: // Returns difference between timestamps in milliseconds static int64_t getDelta(const timespec& a, const timespec& b); + static int64_t getDelta(const timeval& a, const timeval& b); class ExecutionTime {