From dda65cbff0c9a68b0c6efda2a61754065fdee4dc Mon Sep 17 00:00:00 2001 From: Wouter Geraedts Date: Thu, 14 Nov 2019 11:29:49 +0100 Subject: [PATCH] Start throttle measurement before initialisation --- src/stream/stream/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/stream/stream/mod.rs b/src/stream/stream/mod.rs index 99a11203..de4a8fb7 100644 --- a/src/stream/stream/mod.rs +++ b/src/stream/stream/mod.rs @@ -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);