Bläddra i källkod

test(bench) fix clippy lints in benchmarks

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Eliza Weisman 3 år sedan
förälder
incheckning
d9474c626e
3 ändrade filer med 16 tillägg och 18 borttagningar
  1. 5 5
      bench/benches/async_mpsc.rs
  2. 7 7
      bench/benches/async_spsc.rs
  3. 4 6
      bench/benches/sync_spsc.rs

+ 5 - 5
bench/benches/async_mpsc.rs

@@ -56,7 +56,7 @@ aaaaaaaaaaaaaa";
                     for _ in 0..senders {
                         let mut tx = tx.clone();
                         task::spawn(async move {
-                            while let Ok(_) = tx.send(String::from(THE_STRING)).await {}
+                            while tx.send(String::from(THE_STRING)).await.is_ok() {}
                         });
                     }
                     for _ in 0..SIZE {
@@ -122,7 +122,7 @@ aaaaaaaaaaaaaa";
                     for _ in 0..senders {
                         let tx = tx.clone();
                         task::spawn(async move {
-                            while let Ok(_) = tx.send(String::from(THE_STRING)).await {}
+                            while tx.send(String::from(THE_STRING)).await.is_ok() {}
                         });
                     }
                     for _ in 0..SIZE {
@@ -176,7 +176,7 @@ fn bench_mpsc_integer(c: &mut Criterion) {
                     let (tx, mut rx) = mpsc::channel(100);
                     for i in 0..senders {
                         let mut tx = tx.clone();
-                        task::spawn(async move { while let Ok(_) = tx.send(i).await {} });
+                        task::spawn(async move { while tx.send(i).await.is_ok() {} });
                     }
                     for _ in 0..SIZE {
                         let val = rx.next().await.unwrap();
@@ -210,7 +210,7 @@ fn bench_mpsc_integer(c: &mut Criterion) {
                         for i in 0..senders {
                             let tx = tx.clone();
                             task::spawn(tokio::task::unconstrained(async move {
-                                while let Ok(_) = tx.send(i).await {}
+                                while tx.send(i).await.is_ok() {}
                             }));
                         }
                         for _ in 0..SIZE {
@@ -233,7 +233,7 @@ fn bench_mpsc_integer(c: &mut Criterion) {
 
                     for i in 0..senders {
                         let tx = tx.clone();
-                        task::spawn(async move { while let Ok(_) = tx.send(i).await {} });
+                        task::spawn(async move { while tx.send(i).await.is_ok() {} });
                     }
                     for _ in 0..SIZE {
                         let val = rx.recv().await.unwrap();

+ 7 - 7
bench/benches/async_spsc.rs

@@ -182,9 +182,9 @@ aaaaaaaaaaaaaa";
                 b.to_async(rt).iter(|| async {
                     use futures::{channel::mpsc, sink::SinkExt, stream::StreamExt};
                     let (mut tx, mut rx) = mpsc::channel(100);
-                    task::spawn(async move {
-                        while let Ok(_) = tx.send(String::from(THE_STRING)).await {}
-                    });
+                    task::spawn(
+                        async move { while tx.send(String::from(THE_STRING)).await.is_ok() {} },
+                    );
                     for _ in 0..i {
                         let val = rx.next().await.unwrap();
                         criterion::black_box(&val);
@@ -212,7 +212,7 @@ aaaaaaaaaaaaaa";
                     // time ping-ponging through the scheduler than every other
                     // implementation.
                     tokio::task::unconstrained(async {
-                        use tokio::sync::mpsc::{self, error::TrySendError};
+                        use tokio::sync::mpsc;
                         let (tx, mut rx) = mpsc::channel(100);
                         task::spawn(tokio::task::unconstrained(async move {
                             // this actually brings Tokio's MPSC closer to what
@@ -242,9 +242,9 @@ aaaaaaaaaaaaaa";
                 b.to_async(rt).iter(|| async {
                     use async_std::channel;
                     let (tx, rx) = channel::bounded(100);
-                    task::spawn(async move {
-                        while let Ok(_) = tx.send(String::from(THE_STRING)).await {}
-                    });
+                    task::spawn(
+                        async move { while tx.send(String::from(THE_STRING)).await.is_ok() {} },
+                    );
                     for _ in 0..i {
                         let val = rx.recv().await.unwrap();
                         criterion::black_box(&val);

+ 4 - 6
bench/benches/sync_spsc.rs

@@ -130,10 +130,10 @@ aaaaaaaaaaaaaa";
         #[cfg(feature = "std-sync")]
         group.bench_with_input(BenchmarkId::new("std::sync::mpsc", size), &size, |b, &i| {
             b.iter(|| {
-                use std::sync::mpsc::{self, TrySendError};
+                use std::sync::mpsc;
                 let (tx, rx) = mpsc::sync_channel(100);
                 let producer =
-                    thread::spawn(move || while let Ok(_) = tx.send(String::from(THE_STRING)) {});
+                    thread::spawn(move || while tx.send(String::from(THE_STRING)).is_ok() {});
                 for _ in 0..i {
                     let val = rx.recv().unwrap();
                     criterion::black_box(&val);
@@ -149,13 +149,11 @@ aaaaaaaaaaaaaa";
             &size,
             |b, &i| {
                 b.iter(|| {
-                    use crossbeam::channel::{self, TrySendError};
+                    use crossbeam::channel;
                     let (tx, rx) = channel::bounded(100);
 
                     let producer =
-                        thread::spawn(
-                            move || while let Ok(_) = tx.send(String::from(THE_STRING)) {},
-                        );
+                        thread::spawn(move || while tx.send(String::from(THE_STRING)).is_ok() {});
 
                     for _ in 0..i {
                         let val = rx.recv().unwrap();