diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-03-08 23:48:32 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-03-08 23:48:32 +0100 |
| commit | 34385ede2d3726770c3010873e5c7b07b5a0d0ee (patch) | |
| tree | cc00915fe5635fdbaf84f809810f4a225f89be3c /src/linux | |
| parent | 5d9e4b31317e02432c1e7437f1b75f252f968a3e (diff) | |
fix elapsed time on linux
Diffstat (limited to 'src/linux')
| -rw-r--r-- | src/linux/main_linux.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/linux/main_linux.cpp b/src/linux/main_linux.cpp index 2d8cae0..d8907dd 100644 --- a/src/linux/main_linux.cpp +++ b/src/linux/main_linux.cpp @@ -282,15 +282,12 @@ uint64_t ts_platform_get_time(uint64_t compare) { if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID,&tms)) { return -1; } - long result = 0; - result = tms.tv_sec * 1000000; - result += tms.tv_nsec/1000; - if (tms.tv_nsec % 1000 >= 500) { - ++result; - } + uint64_t result = 0; + result = tms.tv_sec * 1000; + result += tms.tv_nsec / 1000000; if (compare != 0) { - return result - compare; + return (result - compare); } return result; |
