forked from mirror/async-std
Start throttle measurement before initialisation
This commit is contained in:
parent
90c67c223a
commit
dda65cbff0
1 changed files with 2 additions and 1 deletions
|
@ -327,6 +327,8 @@ extension_trait! {
|
|||
use async_std::stream;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
let start = Instant::now();
|
||||
|
||||
// emit value every 5 milliseconds
|
||||
let s = stream::interval(Duration::from_millis(5))
|
||||
.enumerate()
|
||||
|
@ -335,7 +337,6 @@ extension_trait! {
|
|||
// 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 >= 5);
|
||||
|
|
Loading…
Reference in a new issue