aboutsummaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2023-03-18 12:17:55 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2023-03-18 12:17:55 +0300
commitde7e611ef0b7c3680f448cc40bae4f57a66800a4 (patch)
tree7d3a77eac6917ad324b37478e8a45643e77365cc /library
parentc4e63099985c9d18877481b71518ade583621f08 (diff)
downloadydb-de7e611ef0b7c3680f448cc40bae4f57a66800a4.tar.gz
Intermediate changes
Diffstat (limited to 'library')
-rw-r--r--library/cpp/yt/cpu_clock/clock-inl.h14
-rw-r--r--library/cpp/yt/cpu_clock/clock.h5
2 files changed, 17 insertions, 2 deletions
diff --git a/library/cpp/yt/cpu_clock/clock-inl.h b/library/cpp/yt/cpu_clock/clock-inl.h
index a69163a428..6402279294 100644
--- a/library/cpp/yt/cpu_clock/clock-inl.h
+++ b/library/cpp/yt/cpu_clock/clock-inl.h
@@ -11,11 +11,23 @@ namespace NYT {
////////////////////////////////////////////////////////////////////////////////
-inline TCpuInstant GetCpuInstant()
+Y_FORCE_INLINE TCpuInstant GetCpuInstant()
{
return static_cast<TCpuInstant>(GetCycleCount());
}
+Y_FORCE_INLINE TCpuInstant GetApproximateCpuInstant()
+{
+#if defined(_x86_64_)
+ ui32 hi, lo;
+ __asm__ __volatile__("rdtsc"
+ : "=a"(lo), "=d"(hi));
+ return static_cast<TCpuInstant>(lo) | (static_cast<TCpuInstant>(hi) << 32);
+#else
+ return GetCpuInstant();
+#endif
+}
+
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT
diff --git a/library/cpp/yt/cpu_clock/clock.h b/library/cpp/yt/cpu_clock/clock.h
index 96f22c3833..9729d1e8eb 100644
--- a/library/cpp/yt/cpu_clock/clock.h
+++ b/library/cpp/yt/cpu_clock/clock.h
@@ -8,9 +8,12 @@ namespace NYT {
////////////////////////////////////////////////////////////////////////////////
-//! Returns the current processor clock (rdtsc).
+//! Returns the current processor clock (typically obtained via |rdtscp| instruction).
TCpuInstant GetCpuInstant();
+//! Returns the approximate current processor clock (obtained via |rdtsc| instruction).
+TCpuInstant GetApproximateCpuInstant();
+
//! Returns the current time (obtained via #GetCpuInstant).
TInstant GetInstant();