xcsp3_rust/utils/
time_interval.rs

1/*
2 * <p>@project_name: xcsp3-rust
3 * </p>
4 * <p>@author: luhan zhen
5 * </p>
6 * <p>@date:  2023/7/21 13:46
7 * </p>
8 * <p>@email: zhenlh20@mails.jlu.edu.cn
9 * </p>
10 * <p>@version: 1.0
11 * </p>
12 * <p>@description:
13 * </p>
14 */
15pub mod xcsp3_utils {
16    use std::time::{Duration, Instant};
17
18    pub struct TimeInterval {
19        start: Instant,
20    }
21
22    impl TimeInterval {
23        pub fn new() -> Self {
24            Self {
25                start: Instant::now(),
26            }
27        }
28
29        pub fn get(&self) -> Duration {
30            self.start.elapsed()
31        }
32    }
33
34    impl Default for TimeInterval {
35        fn default() -> Self {
36            Self::new()
37        }
38    }
39}