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
//! # Time Utilities
//!
//! This module helps you with time in the desktop simulation environment.
//!
//! ## Example
//!
//! ```rust,no_run
//! use blinksy_desktop::time::elapsed_in_ms;
//!
//! loop {
//! // Get the current time in milliseconds
//! let current_time = elapsed_in_ms();
//!
//! // Use this time to update your animations
//! // control.tick(current_time);
//!
//! // Sleep to limit frame rate
//! std::thread::sleep(std::time::Duration::from_millis(16));
//! }
//! ```
use OnceLock;
use Instant;
static START_TIME: = new;
/// Returns the number of milliseconds elapsed since the program started. This is useful to pass
/// into `control.tick`.
///
/// It initializes a static timer on first call and then measures elapsed time
/// from that point.
///
/// # Returns
///
/// The number of milliseconds since program start or first call to this function