|
1 | 1 | //! A command which prints the current values of the realtime and monotonic |
2 | 2 | //! clocks it's given. |
3 | 3 |
|
4 | | -#[cfg(not(any(windows, target_os = "espidf")))] |
5 | | -#[cfg(feature = "time")] |
6 | | -struct DebugTimespec(rustix::time::Timespec); |
7 | | - |
8 | | -#[cfg(not(any(windows, target_os = "espidf")))] |
9 | | -#[cfg(feature = "time")] |
10 | | -impl core::fmt::Debug for DebugTimespec { |
11 | | - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { |
12 | | - let mut d = f.debug_struct("Timespec"); |
13 | | - d.field("tv_sec", &self.0.tv_sec); |
14 | | - d.field("tv_nsec", &self.0.tv_nsec); |
15 | | - d.finish() |
16 | | - } |
17 | | -} |
18 | | - |
19 | 4 | #[cfg(not(any(windows, target_os = "espidf")))] |
20 | 5 | #[cfg(feature = "time")] |
21 | 6 | fn main() { |
22 | 7 | use rustix::time::{clock_gettime, ClockId}; |
23 | 8 |
|
24 | | - println!( |
25 | | - "Real time: {:?}", |
26 | | - DebugTimespec(clock_gettime(ClockId::Realtime)) |
27 | | - ); |
28 | | - println!( |
29 | | - "Monotonic time: {:?}", |
30 | | - DebugTimespec(clock_gettime(ClockId::Monotonic)) |
31 | | - ); |
| 9 | + println!("Real time: {:?}", clock_gettime(ClockId::Realtime)); |
| 10 | + println!("Monotonic time: {:?}", clock_gettime(ClockId::Monotonic)); |
32 | 11 |
|
33 | 12 | #[cfg(any(freebsdlike, target_os = "openbsd"))] |
34 | 13 | println!("Uptime: {:?}", clock_gettime(ClockId::Uptime)); |
35 | 14 |
|
36 | 15 | #[cfg(not(any(solarish, target_os = "netbsd", target_os = "redox")))] |
37 | 16 | println!( |
38 | 17 | "Process CPU time: {:?}", |
39 | | - DebugTimespec(clock_gettime(ClockId::ProcessCPUTime)) |
| 18 | + clock_gettime(ClockId::ProcessCPUTime) |
40 | 19 | ); |
41 | 20 |
|
42 | 21 | #[cfg(not(any(solarish, target_os = "netbsd", target_os = "redox")))] |
43 | 22 | println!( |
44 | 23 | "Thread CPU time: {:?}", |
45 | | - DebugTimespec(clock_gettime(ClockId::ThreadCPUTime)) |
| 24 | + clock_gettime(ClockId::ThreadCPUTime) |
46 | 25 | ); |
47 | 26 |
|
48 | 27 | #[cfg(any(linux_kernel, target_os = "freebsd"))] |
49 | 28 | println!( |
50 | 29 | "Realtime (coarse): {:?}", |
51 | | - DebugTimespec(clock_gettime(ClockId::RealtimeCoarse)) |
| 30 | + clock_gettime(ClockId::RealtimeCoarse) |
52 | 31 | ); |
53 | 32 |
|
54 | 33 | #[cfg(any(linux_kernel, target_os = "freebsd"))] |
55 | 34 | println!( |
56 | 35 | "Monotonic (coarse): {:?}", |
57 | | - DebugTimespec(clock_gettime(ClockId::MonotonicCoarse)) |
| 36 | + clock_gettime(ClockId::MonotonicCoarse) |
58 | 37 | ); |
59 | 38 |
|
60 | 39 | #[cfg(linux_kernel)] |
61 | 40 | println!( |
62 | 41 | "Monotonic (raw): {:?}", |
63 | | - DebugTimespec(clock_gettime(ClockId::MonotonicRaw)) |
| 42 | + clock_gettime(ClockId::MonotonicRaw) |
64 | 43 | ); |
65 | 44 | } |
66 | 45 |
|
|
0 commit comments