Skip to content

Commit

Permalink
clippy isn't always right (mozilla#2193)
Browse files Browse the repository at this point in the history
Sometimes, you have to tell it to be quiet.

And sometimes, it misses an obvious improvement.
  • Loading branch information
martinthomson authored Oct 21, 2024
1 parent 66b9c8c commit 618f31c
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions neqo-transport/benches/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ use test_fixture::{
sim::{
connection::{ConnectionNode, ReachState, ReceiveData, SendData},
network::{Delay, TailDrop},
Simulator,
ReadySimulator, Simulator,
},
};

const ZERO: Duration = Duration::from_millis(0);
const JITTER: Duration = Duration::from_millis(10);
const TRANSFER_AMOUNT: usize = 1 << 22; // 4Mbyte

fn benchmark_transfer(c: &mut Criterion, label: &str, seed: Option<&impl AsRef<str>>) {
#[allow(clippy::needless_pass_by_value)] // Passing String where &str would do is fine here.
fn benchmark_transfer(c: &mut Criterion, label: &str, seed: Option<impl AsRef<str>>) {
for pacing in [false, true] {
let mut group = c.benchmark_group(format!("transfer/pacing-{pacing}"));
// Don't let criterion calculate throughput, as that's based on wall-clock time, not
Expand Down Expand Up @@ -52,9 +53,7 @@ fn benchmark_transfer(c: &mut Criterion, label: &str, seed: Option<&impl AsRef<s
}
sim.setup()
},
|sim| {
sim.run();
},
ReadySimulator::run,
SmallInput,
);
});
Expand All @@ -63,18 +62,14 @@ fn benchmark_transfer(c: &mut Criterion, label: &str, seed: Option<&impl AsRef<s
}

fn benchmark_transfer_variable(c: &mut Criterion) {
benchmark_transfer(
c,
"varying-seeds",
std::env::var("SIMULATION_SEED").ok().as_ref(),
);
benchmark_transfer(c, "varying-seeds", std::env::var("SIMULATION_SEED").ok());
}

fn benchmark_transfer_fixed(c: &mut Criterion) {
benchmark_transfer(
c,
"same-seed",
Some(&"62df6933ba1f543cece01db8f27fb2025529b27f93df39e19f006e1db3b8c843"),
Some("62df6933ba1f543cece01db8f27fb2025529b27f93df39e19f006e1db3b8c843"),
);
}

Expand Down

0 comments on commit 618f31c

Please sign in to comment.