diff options
author | nga <nga@yandex-team.ru> | 2022-02-10 16:48:09 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:09 +0300 |
commit | 1f553f46fb4f3c5eec631352cdd900a0709016af (patch) | |
tree | a231fba2c03b440becaea6c86a2702d0bfb0336e /util/system/datetime.cpp | |
parent | c4de7efdedc25b49cbea74bd589eecb61b55b60a (diff) | |
download | ydb-1f553f46fb4f3c5eec631352cdd900a0709016af.tar.gz |
Restoring authorship annotation for <nga@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/system/datetime.cpp')
-rw-r--r-- | util/system/datetime.cpp | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/util/system/datetime.cpp b/util/system/datetime.cpp index b07b50679a..4c5488a24c 100644 --- a/util/system/datetime.cpp +++ b/util/system/datetime.cpp @@ -7,7 +7,7 @@ #include <ctime> #include <cerrno> - + #ifdef _darwin_ #include <AvailabilityMacros.h> #if defined(MAC_OS_X_VERSION_10_12) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 @@ -19,8 +19,8 @@ static ui64 ToMicroSeconds(const struct timeval& tv) { return (ui64)tv.tv_sec * 1000000 + (ui64)tv.tv_usec; -} - +} + #if defined(_win_) static ui64 ToMicroSeconds(const FILETIME& ft) { return (((ui64)ft.dwHighDateTime << 32) + (ui64)ft.dwLowDateTime) / (ui64)10; @@ -32,12 +32,12 @@ static ui64 ToMicroSeconds(const struct timespec& ts) { #endif ui64 MicroSeconds() noexcept { - struct timeval tv; + struct timeval tv; gettimeofday(&tv, nullptr); - + return ToMicroSeconds(tv); -} - +} + ui64 ThreadCPUUserTime() noexcept { #if defined(_win_) FILETIME creationTime, exitTime, kernelTime, userTime; @@ -73,26 +73,26 @@ ui64 ThreadCPUTime() noexcept { } ui32 Seconds() noexcept { - struct timeval tv; + struct timeval tv; gettimeofday(&tv, nullptr); - return tv.tv_sec; -} - + return tv.tv_sec; +} + void NanoSleep(ui64 ns) noexcept { #if defined(_win_) - Sleep(ns / 1000000); -#else - const ui64 NS = 1000 * 1000 * 1000; - struct timespec req; - req.tv_sec = ns / NS; - req.tv_nsec = ns % NS; - struct timespec left; - while (nanosleep(&req, &left) < 0) { + Sleep(ns / 1000000); +#else + const ui64 NS = 1000 * 1000 * 1000; + struct timespec req; + req.tv_sec = ns / NS; + req.tv_nsec = ns % NS; + struct timespec left; + while (nanosleep(&req, &left) < 0) { Y_ASSERT(errno == EINTR); - req = left; - } -#endif -} + req = left; + } +#endif +} #if defined(_x86_) extern const bool HaveRdtscp = NX86::HaveRDTSCP(); |