aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/cpu_clock/clock.h
blob: 9729d1e8eba17a05bbcb5b29e6a00f3243715bf3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once

#include "public.h"

#include <util/datetime/base.h>

namespace NYT {

////////////////////////////////////////////////////////////////////////////////

//! 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();

//! Converts a number of processor ticks into a regular duration.
TDuration CpuDurationToDuration(TCpuDuration cpuDuration);

//! Converts a regular duration into the number of processor ticks.
TCpuDuration DurationToCpuDuration(TDuration duration);

//! Converts a processor clock into the regular time instant.
TInstant CpuInstantToInstant(TCpuInstant cpuInstant);

//! Converts a regular time instant into the processor clock.
TCpuInstant InstantToCpuInstant(TInstant instant);

////////////////////////////////////////////////////////////////////////////////

} // namespace NYT

#define CLOCK_INL_H_
#include "clock-inl.h"
#undef CLOCK_INL_H_