Skip to content

Commit

Permalink
Correct bench
Browse files Browse the repository at this point in the history
  • Loading branch information
olegnn committed Jun 10, 2022
1 parent b59da8a commit c8f4866
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions futures-util/benches/flatten_unordered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use futures::executor::block_on;
use futures::future;
use futures::stream::{self, StreamExt};
use futures::task::Poll;
use futures_util::FutureExt;
use std::collections::VecDeque;
use std::thread;

Expand All @@ -34,17 +35,9 @@ fn oneshot_streams(b: &mut Bencher) {
}
});

let mut flatten = stream::unfold(rxs.into_iter(), |mut vals| {
Box::pin(async {
if let Some(next) = vals.next() {
let val = next.await.unwrap();
Some((val, vals))
} else {
None
}
})
})
.flatten_unordered(None);
let mut flatten = stream::iter(rxs)
.map(|recv| recv.into_stream().map(|val| val.unwrap()).flatten())
.flatten_unordered(None);

block_on(future::poll_fn(move |cx| {
let mut count = 0;
Expand Down

0 comments on commit c8f4866

Please sign in to comment.