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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
//! The `clock` module returns time values derived from the Posix / C
//! [CLOCK_GETTIME](http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html)
//! function or equivalent.
//!
//! Most functions in the module return a number of seconds; functions with names followed by “64”
//! return a 64-bit number of nanoseconds.
//!
//! - [time()](fn.time.html) - Get the wall clock time in seconds
//! - [time64()](fn.time64.html) - Get the wall clock time in nanoseconds
//! - [monotonic()](fn.monotonic.html) - Get the monotonic time in seconds
//! - [monotonic64()](fn.monotonic64.html) - Get the monotonic time in nanoseconds
//! - [proc()](fn.proc.html) - Get the processor time in seconds
//! - [proc64()](fn.proc64.html) - Get the processor time in nanoseconds
//! - [thread()](fn.thread.html) - Get the thread time in seconds
//! - [thread64()](fn.thread64.html) - Get the thread time in nanoseconds
//!
//! See also:
//! - [Lua reference: Module clock](https://www.tarantool.io/en/doc/latest/reference/reference_lua/clock/)
//! - [C API reference: Module clock](https://www.tarantool.io/en/doc/latest/dev_guide/reference_capi/clock/)
use Duration;
/// A large duration, effectively infinite for all practical purposes.
///
/// This value can be used as a default timeout value whenever there's no
/// obvious limit but the API requires an explicit value.
///
/// Is equivalent to 100 years.
pub const INFINITY: Duration = from_secs;
use cratetarantool as ffi;
/// The wall clock time in seconds.
///
/// Derived from C function `clock_gettime(CLOCK_REALTIME)`.
/// This is the best function for knowing what the official time is, as determined by the system administrator.
///
/// Return: seconds since epoch (1970-01-01 00:00:00), adjusted.
///
/// Example:
/// ```no_run
/// // This will print an approximate number of years since 1970.
/// use tarantool::clock::time;
/// println!("{}", time() / (365. * 24. * 60. * 60.));
/// ```
///
/// See also: [fiber::time()](../fiber/fn.time.html), [fiber::time64()](../fiber/fn.time64.html)
/// The wall clock time in nanoseconds since epoch.
///
/// Example:
/// ```no_run
/// // This will print an approximate number of years since 1970.
/// use tarantool::clock::time64;
/// println!("{}", time64() / (365 * 24 * 60 * 60));
/// ```
/// See: [time()](fn.time.html)
/// The monotonic time.
///
/// Derived from C function `clock_gettime(CLOCK_MONOTONIC)`.
/// Monotonic time is similar to wall clock time but is not affected by changes to or from daylight saving time, or by
/// changes done by a user. This is the best function to use with benchmarks that need to calculate elapsed time.
///
/// Return: seconds or nanoseconds since the last time that the computer was booted.
/// Return type: `u64` or `f64`
///
/// Example:
/// ```no_run
/// // This will print nanoseconds since the start.
/// use tarantool::clock::monotonic64;
/// println!("{}", monotonic64());
/// ```
/// See: [monotonic()](fn.monotonic.html)
/// The processor time.
///
/// Derived from C function `clock_gettime(CLOCK_PROCESS_CPUTIME_ID)`.
/// This is the best function to use with benchmarks that need to calculate the amount of time for which CPU was used.
///
/// Return: seconds or nanoseconds since processor start.
/// Return type: `u64` or `f64`
///
/// Example:
/// ```no_run
/// // This will print nanoseconds in the CPU since the start.
/// use tarantool::clock::process64;
/// println!("{}", process64());
/// ```
/// See: [process()](fn.process.html)
/// The thread time.
///
/// Derived from C function `clock_gettime(CLOCK_THREAD_CPUTIME_ID)`.
/// This is the best function to use with benchmarks that need to calculate hthe amount of time for which a CPU thread was used.
///
/// Return: seconds or nanoseconds since the transaction processor thread started.
/// Return type: `u64` or `f64`
///
/// Example:
/// ```no_run
/// // This will print seconds in the thread since the start.
/// use tarantool::clock::thread64;
/// println!("{}", thread64());
/// ```
/// See: [thread()](fn.thread.html)