aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAria Shrimpton <me@aria.rip>2024-01-23 13:43:35 +0000
committerAria Shrimpton <me@aria.rip>2024-01-23 13:43:35 +0000
commitefa6269ca600e57e67f860a1ec420ac80c30acd9 (patch)
tree39ee82db00207bbd933ac70bb51810f95047a530
parent1cfb58a4012e2774f6d2eb507e3e7f361cb4154f (diff)
lints
-rw-r--r--src/crates/benchmarker/src/container.rs8
-rw-r--r--src/crates/benchmarker/src/stack.rs4
-rw-r--r--src/crates/candelabra/src/cost/benchmark.rs2
-rw-r--r--src/crates/cli/src/estimate.rs2
-rw-r--r--src/crates/cli/src/select.rs7
-rw-r--r--src/tests/prime_sieve/benches/main.rs10
6 files changed, 16 insertions, 17 deletions
diff --git a/src/crates/benchmarker/src/container.rs b/src/crates/benchmarker/src/container.rs
index 004c639..157ab90 100644
--- a/src/crates/benchmarker/src/container.rs
+++ b/src/crates/benchmarker/src/container.rs
@@ -26,8 +26,8 @@ where
let mut results = benchmark_op(
|| (T::default(), (0..n).map(|_| random()).collect::<Vec<E>>()),
|(c, xs)| {
- for i in 0..n {
- c.insert(xs[i]);
+ for x in xs {
+ c.insert(*x);
}
},
);
@@ -59,7 +59,7 @@ where
c.insert(random());
}
let chosen = rng.gen();
- c.insert(chosen.clone());
+ c.insert(chosen);
for _ in pivot..n {
c.insert(random());
}
@@ -93,7 +93,7 @@ where
c.insert(random());
}
let chosen = rng.gen();
- c.insert(chosen.clone());
+ c.insert(chosen);
for _ in pivot..n {
c.insert(random());
}
diff --git a/src/crates/benchmarker/src/stack.rs b/src/crates/benchmarker/src/stack.rs
index 2f82e0f..93ba962 100644
--- a/src/crates/benchmarker/src/stack.rs
+++ b/src/crates/benchmarker/src/stack.rs
@@ -26,8 +26,8 @@ where
let mut results = benchmark_op(
|| (T::default(), (0..n).map(|_| random()).collect::<Vec<E>>()),
|(c, xs)| {
- for i in 0..n {
- c.push(xs[i]);
+ for x in xs {
+ c.push(*x);
}
},
);
diff --git a/src/crates/candelabra/src/cost/benchmark.rs b/src/crates/candelabra/src/cost/benchmark.rs
index 48c7a84..17164a1 100644
--- a/src/crates/candelabra/src/cost/benchmark.rs
+++ b/src/crates/candelabra/src/cost/benchmark.rs
@@ -113,7 +113,7 @@ pub(crate) fn tee_output(mut child: Child) -> Result<String> {
}
// Deserialise benchmark results
- Ok(String::from_utf8(output).context("Error interpreting output as UTF-8")?)
+ String::from_utf8(output).context("Error interpreting output as UTF-8")
}
pub(crate) fn parse_criterion_output(
diff --git a/src/crates/cli/src/estimate.rs b/src/crates/cli/src/estimate.rs
index 9618fb6..6915afd 100644
--- a/src/crates/cli/src/estimate.rs
+++ b/src/crates/cli/src/estimate.rs
@@ -48,7 +48,7 @@ impl State {
let profiler = profile_info
.get(*con_type_name)
.ok_or_else(|| anyhow!("no profiling info for {} - wrong name?", con_type_name))?;
- let cost_model = self.inner.cost_model(&impl_name)?;
+ let cost_model = self.inner.cost_model(impl_name)?;
let breakdown = profiler.cost_breakdown(&cost_model);
acc.insert(
*con_type_name,
diff --git a/src/crates/cli/src/select.rs b/src/crates/cli/src/select.rs
index 5b9b755..c415d03 100644
--- a/src/crates/cli/src/select.rs
+++ b/src/crates/cli/src/select.rs
@@ -80,11 +80,8 @@ impl State {
for (assignment, benchmark_results) in assignments_results.iter() {
let mut record = vec![assignment.to_string()];
- for i in 1..header.len() {
- record.push(format!(
- "{:?}",
- benchmark_results.get(header[i]).unwrap().avg
- ));
+ for key in header.iter().skip(1) {
+ record.push(format!("{:?}", benchmark_results.get(*key).unwrap().avg));
}
builder.push_record(record);
}
diff --git a/src/tests/prime_sieve/benches/main.rs b/src/tests/prime_sieve/benches/main.rs
index a055c26..e75a589 100644
--- a/src/tests/prime_sieve/benches/main.rs
+++ b/src/tests/prime_sieve/benches/main.rs
@@ -3,14 +3,16 @@ use criterion::Criterion;
use criterion::{criterion_group, criterion_main};
fn bench_sieve(c: &mut Criterion) {
- let mut group = c.benchmark_group("prime_sieve");
- group.sample_size(20);
for size in [10_000, 20_000, 50_000].iter() {
- group.bench_with_input(BenchmarkId::new("prime_sieve", size), size, |b, &n| {
+ c.bench_with_input(BenchmarkId::new("prime_sieve", size), size, |b, &n| {
b.iter(|| prime_sieve::prime_sieve(n));
});
}
}
-criterion_group!(benches, bench_sieve);
+criterion_group!(
+ name = benches;
+ config = Criterion::default().sample_size(20);
+ targets = bench_sieve
+);
criterion_main!(benches);