/
githubmirror
/
nbs
Обзор
Документация
Войти
/
githubmirror
/
nbs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
library/cpp/yt/cpu_clock/unittests/clock_ut.cpp
46 строк
1 KB
Anton Myagkov
Update ydb version to 24.4 (#4579)
07 фев 2026, 11:59
Не верифицирован
07 фев 2026, 11:59
2c21cae
Код
Авторство
О чём код?
#include <gtest/gtest.h> #include <library/cpp/yt/cpu_clock/clock.h> namespace NYT { namespace { //////////////////////////////////////////////////////////////////////////////// template <class T> i64 DiffMS(T a, T b) { return a >= b ? static_cast<i64>(a.MilliSeconds()) - static_cast<i64>(b.MilliSeconds()) : DiffMS(b, a); } TEST(TTimingTest, GetInstant) { GetInstant(); EXPECT_LE(DiffMS(GetInstant(), TInstant::Now()), 10); } TEST(TTimingTest, InstantVSCpuInstant) { auto instant1 = TInstant::Now(); auto cpuInstant = InstantToCpuInstant(instant1); auto instant2 = CpuInstantToInstant(cpuInstant); EXPECT_LE(DiffMS(instant1, instant2), 10); } TEST(TTimingTest, DurationVSCpuDuration) { auto cpuInstant1 = GetCpuInstant(); constexpr auto duration1 = TDuration::MilliSeconds(100); Sleep(duration1); auto cpuInstant2 = GetCpuInstant(); auto duration2 = CpuDurationToDuration(cpuInstant2 - cpuInstant1); EXPECT_LE(DiffMS(duration1, duration2), 10); } //////////////////////////////////////////////////////////////////////////////// } // namespace } // namespace NYT