We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9458edf commit d473981Copy full SHA for d473981
tests/pass/shims/time-with-isolation.rs
@@ -1,11 +1,5 @@
1
use std::time::{Duration, Instant};
2
3
-fn duration_sanity(diff: Duration) {
4
- // On my laptop, I observed times around 15-40ms. Add 10x lee-way both ways.
5
- assert!(diff.as_millis() > 1);
6
- assert!(diff.as_millis() < 500);
7
-}
8
-
9
fn test_sleep() {
10
let before = Instant::now();
11
std::thread::sleep(Duration::from_millis(100));
@@ -26,7 +20,9 @@ fn main() {
26
20
let diff = now2.duration_since(now1);
27
21
assert_eq!(now1 + diff, now2);
28
22
assert_eq!(now2 - diff, now1);
29
- duration_sanity(diff);
23
+ // The virtual clock is deterministic and I got 29us. This should be updated if
24
+ // `NANOSECONDS_PER_BASIC_BLOCK` changes.
25
+ assert_eq!(diff.as_micros(), 29);
30
31
test_sleep();
32
}
0 commit comments