Decreased throttle test time to original values; only test lower bound

new-scheduler
Wouter Geraedts 5 years ago
parent c5b3a98e5b
commit 90c67c223a

@ -327,30 +327,30 @@ extension_trait! {
use async_std::stream;
use std::time::{Duration, Instant};
// emit value every 50 milliseconds
let s = stream::interval(Duration::from_millis(50))
// emit value every 5 milliseconds
let s = stream::interval(Duration::from_millis(5))
.enumerate()
.take(3);
// throttle for 100 milliseconds
let mut s = s.throttle(Duration::from_millis(100));
// throttle for 10 milliseconds
let mut s = s.throttle(Duration::from_millis(10));
let start = Instant::now();
assert_eq!(s.next().await, Some((0, ())));
let duration_ms = start.elapsed().as_millis();
assert!(duration_ms >= 50 && duration_ms < 150);
assert!(duration_ms >= 5);
assert_eq!(s.next().await, Some((1, ())));
let duration_ms = start.elapsed().as_millis();
assert!(duration_ms >= 150 && duration_ms < 250);
assert!(duration_ms >= 15);
assert_eq!(s.next().await, Some((2, ())));
let duration_ms = start.elapsed().as_millis();
assert!(duration_ms >= 250 && duration_ms < 350);
assert!(duration_ms >= 25);
assert_eq!(s.next().await, None);
let duration_ms = start.elapsed().as_millis();
assert!(duration_ms >= 350 && duration_ms < 450);
assert!(duration_ms >= 35);
#
# }) }
```

Loading…
Cancel
Save