Skip to content

Commit

Permalink
clippy: Fix semicolon_if_nothing_returned lints
Browse files Browse the repository at this point in the history
  • Loading branch information
waywardmonkeys committed Jul 10, 2024
1 parent 3c3982c commit 3d9a9a0
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 48 deletions.
6 changes: 3 additions & 3 deletions benches/benchmarks/compare_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ fn compare_fibonaccis_group(c: &mut Criterion) {
let mut group = c.benchmark_group("Fibonacci3");
for i in 20..=21 {
group.bench_with_input(BenchmarkId::new("Recursive", i), &i, |b, i| {
b.iter(|| fibonacci_slow(*i))
b.iter(|| fibonacci_slow(*i));
});
group.bench_with_input(BenchmarkId::new("Iterative", i), &i, |b, i| {
b.iter(|| fibonacci_fast(*i))
b.iter(|| fibonacci_fast(*i));
});
}
group.finish()
group.finish();
}

criterion_group!(fibonaccis, compare_fibonaccis, compare_fibonaccis_group,);
6 changes: 3 additions & 3 deletions benches/benchmarks/custom_measurement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ impl ValueFormatter for HalfSecFormatter {
match *throughput {
Throughput::Bytes(bytes) | Throughput::BytesDecimal(bytes) => {
for val in values {
*val = (bytes as f64) / (*val * 2f64 * 10f64.powi(-9))
*val = (bytes as f64) / (*val * 2f64 * 10f64.powi(-9));
}

"b/s/2"
}
Throughput::Elements(elems) => {
for val in values {
*val = (elems as f64) / (*val * 2f64 * 10f64.powi(-9))
*val = (elems as f64) / (*val * 2f64 * 10f64.powi(-9));
}

"elem/s/2"
Expand Down Expand Up @@ -103,7 +103,7 @@ fn fibonacci_slow(n: u64) -> u64 {

fn fibonacci_cycles(criterion: &mut Criterion<HalfSeconds>) {
criterion.bench_function("fibonacci_custom_measurement", |bencher| {
bencher.iter(|| fibonacci_slow(black_box(10)))
bencher.iter(|| fibonacci_slow(black_box(10)));
});
}

Expand Down
2 changes: 1 addition & 1 deletion benches/benchmarks/external_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn python_fibonacci(c: &mut Criterion) {
let nanoseconds: u64 =
u64::from_str(line.trim()).expect("Unable to parse time from child process");
Duration::from_nanos(nanoseconds)
})
});
});

// Ensure that your child process terminates itself gracefully!
Expand Down
4 changes: 2 additions & 2 deletions benches/benchmarks/iter_with_large_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ fn large_setup(c: &mut Criterion) {
|| (0..SIZE).map(|i| i as u8).collect::<Vec<_>>(),
|v| v,
BatchSize::NumBatches(1),
)
);
});
}

fn small_setup(c: &mut Criterion) {
let mut group = c.benchmark_group("iter_with_large_setup");
group.bench_function("small_setup", |b| {
b.iter_batched(|| SIZE, |size| size, BatchSize::NumBatches(1))
b.iter_batched(|| SIZE, |size| size, BatchSize::NumBatches(1));
});
}

Expand Down
2 changes: 1 addition & 1 deletion benches/benchmarks/iter_with_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const SIZE: usize = 1024 * 1024;

fn setup(c: &mut Criterion) {
c.bench_function("iter_with_setup", |b| {
b.iter_with_setup(|| (0..SIZE).map(|i| i as u8).collect::<Vec<_>>(), |v| v)
b.iter_with_setup(|| (0..SIZE).map(|i| i as u8).collect::<Vec<_>>(), |v| v);
});
}

Expand Down
14 changes: 7 additions & 7 deletions benches/benchmarks/measurement_overhead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ fn some_benchmark(c: &mut Criterion) {
group.bench_function("iter", |b| b.iter(|| 1));
group.bench_function("iter_with_setup", |b| b.iter_with_setup(|| (), |_| 1));
group.bench_function("iter_with_large_setup", |b| {
b.iter_batched(|| (), |_| 1, BatchSize::NumBatches(1))
b.iter_batched(|| (), |_| 1, BatchSize::NumBatches(1));
});
group.bench_function("iter_with_large_drop", |b| b.iter_with_large_drop(|| 1));
group.bench_function("iter_batched_small_input", |b| {
b.iter_batched(|| (), |_| 1, BatchSize::SmallInput)
b.iter_batched(|| (), |_| 1, BatchSize::SmallInput);
});
group.bench_function("iter_batched_large_input", |b| {
b.iter_batched(|| (), |_| 1, BatchSize::LargeInput)
b.iter_batched(|| (), |_| 1, BatchSize::LargeInput);
});
group.bench_function("iter_batched_per_iteration", |b| {
b.iter_batched(|| (), |_| 1, BatchSize::PerIteration)
b.iter_batched(|| (), |_| 1, BatchSize::PerIteration);
});
group.bench_function("iter_batched_ref_small_input", |b| {
b.iter_batched_ref(|| (), |_| 1, BatchSize::SmallInput)
b.iter_batched_ref(|| (), |_| 1, BatchSize::SmallInput);
});
group.bench_function("iter_batched_ref_large_input", |b| {
b.iter_batched_ref(|| (), |_| 1, BatchSize::LargeInput)
b.iter_batched_ref(|| (), |_| 1, BatchSize::LargeInput);
});
group.bench_function("iter_batched_ref_per_iteration", |b| {
b.iter_batched_ref(|| (), |_| 1, BatchSize::PerIteration)
b.iter_batched_ref(|| (), |_| 1, BatchSize::PerIteration);
});
group.finish();
}
Expand Down
6 changes: 3 additions & 3 deletions benches/benchmarks/sampling_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ fn sampling_mode_tests(c: &mut Criterion) {

group.sampling_mode(SamplingMode::Auto);
group.bench_function("Auto", |bencher| {
bencher.iter(|| sleep(Duration::from_millis(0)))
bencher.iter(|| sleep(Duration::from_millis(0)));
});

group.sampling_mode(SamplingMode::Linear);
group.bench_function("Linear", |bencher| {
bencher.iter(|| sleep(Duration::from_millis(0)))
bencher.iter(|| sleep(Duration::from_millis(0)));
});

group.sampling_mode(SamplingMode::Flat);
group.bench_function("Flat", |bencher| {
bencher.iter(|| sleep(Duration::from_millis(10)))
bencher.iter(|| sleep(Duration::from_millis(10)));
});

group.finish();
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ https://bheisler.github.io/criterion.rs/book/faq.html

if let Some(dir) = matches.get_one::<String>("save-baseline") {
self.baseline = Baseline::Save;
dir.clone_into(&mut self.baseline_directory)
dir.clone_into(&mut self.baseline_directory);
}
if matches.get_flag("discard-baseline") {
self.baseline = Baseline::Discard;
Expand Down
6 changes: 3 additions & 3 deletions src/plot/plotters_backend/distributions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ pub(crate) fn abs_distributions(
distribution,
estimate,
size,
)
})
);
});
}

fn rel_distribution(
Expand Down Expand Up @@ -303,6 +303,6 @@ pub(crate) fn rel_distributions(
comparison.relative_estimates.get(statistic),
comparison.noise_threshold,
size,
)
);
});
}
4 changes: 2 additions & 2 deletions src/plot/plotters_backend/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn line_comparison(

match axis_scale {
AxisScale::Linear => {
draw_line_comarision_figure(root_area, unit, x_range, y_range, value_type, series_data)
draw_line_comarision_figure(root_area, unit, x_range, y_range, value_type, series_data);
}
AxisScale::Logarithmic => draw_line_comarision_figure(
root_area,
Expand Down Expand Up @@ -209,7 +209,7 @@ pub fn violin(
match axis_scale {
AxisScale::Linear => draw_violin_figure(root_area, unit, x_range, y_range, kdes),
AxisScale::Logarithmic => {
draw_violin_figure(root_area, unit, x_range.log_scale(), y_range, kdes)
draw_violin_figure(root_area, unit, x_range.log_scale(), y_range, kdes);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ impl CliReport {

fn text_overwrite(&self) {
if self.enable_text_overwrite {
eprint!("\r{}", ClearLine::All)
eprint!("\r{}", ClearLine::All);
}
}

Expand Down Expand Up @@ -590,7 +590,7 @@ impl Report for CliReport {
throughput,
typical_estimate.confidence_interval.lower_bound
)),
)
);
}

if !matches!(self.verbosity, CliVerbosity::Quiet) {
Expand Down
4 changes: 2 additions & 2 deletions src/stats/univariate/resamples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ where

for _ in 0..n {
let idx = rng.rand_range(0u64..(self.sample.len() as u64));
stage.push(self.sample[idx as usize])
stage.push(self.sample[idx as usize]);
}

self.stage = Some(stage);
}
Some(ref mut stage) => {
for elem in stage.iter_mut() {
let idx = rng.rand_range(0u64..(self.sample.len() as u64));
*elem = self.sample[idx as usize]
*elem = self.sample[idx as usize];
}
}
}
Expand Down
36 changes: 18 additions & 18 deletions tests/criterion_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ fn test_sample_size() {
.sample_size(50)
.bench_function("test_sample_size", move |b| {
clone.count();
b.iter(|| 10)
b.iter(|| 10);
});

// This function will be called more than sample_size times because of the
Expand All @@ -215,7 +215,7 @@ fn test_warmup_time() {
.warm_up_time(Duration::from_millis(100))
.bench_function("test_warmup_time_1", move |b| {
clone.count();
b.iter(|| 10)
b.iter(|| 10);
});

let counter2 = Counter::default();
Expand All @@ -224,7 +224,7 @@ fn test_warmup_time() {
.warm_up_time(Duration::from_millis(2000))
.bench_function("test_warmup_time_2", move |b| {
clone.count();
b.iter(|| 10)
b.iter(|| 10);
});

assert!(counter1.read() < counter2.read());
Expand Down Expand Up @@ -275,43 +275,43 @@ fn test_timing_loops() {
let mut c = short_benchmark(&dir);
let mut group = c.benchmark_group("test_timing_loops");
group.bench_function("iter_with_setup", |b| {
b.iter_with_setup(|| vec![10], |v| v[0])
b.iter_with_setup(|| vec![10], |v| v[0]);
});
group.bench_function("iter_with_large_setup", |b| {
b.iter_batched(|| vec![10], |v| v[0], BatchSize::NumBatches(1))
b.iter_batched(|| vec![10], |v| v[0], BatchSize::NumBatches(1));
});
group.bench_function("iter_with_large_drop", |b| {
b.iter_with_large_drop(|| vec![10; 100])
b.iter_with_large_drop(|| vec![10; 100]);
});
group.bench_function("iter_batched_small", |b| {
b.iter_batched(|| vec![10], |v| v[0], BatchSize::SmallInput)
b.iter_batched(|| vec![10], |v| v[0], BatchSize::SmallInput);
});
group.bench_function("iter_batched_large", |b| {
b.iter_batched(|| vec![10], |v| v[0], BatchSize::LargeInput)
b.iter_batched(|| vec![10], |v| v[0], BatchSize::LargeInput);
});
group.bench_function("iter_batched_per_iteration", |b| {
b.iter_batched(|| vec![10], |v| v[0], BatchSize::PerIteration)
b.iter_batched(|| vec![10], |v| v[0], BatchSize::PerIteration);
});
group.bench_function("iter_batched_one_batch", |b| {
b.iter_batched(|| vec![10], |v| v[0], BatchSize::NumBatches(1))
b.iter_batched(|| vec![10], |v| v[0], BatchSize::NumBatches(1));
});
group.bench_function("iter_batched_10_iterations", |b| {
b.iter_batched(|| vec![10], |v| v[0], BatchSize::NumIterations(10))
b.iter_batched(|| vec![10], |v| v[0], BatchSize::NumIterations(10));
});
group.bench_function("iter_batched_ref_small", |b| {
b.iter_batched_ref(|| vec![10], |v| v[0], BatchSize::SmallInput)
b.iter_batched_ref(|| vec![10], |v| v[0], BatchSize::SmallInput);
});
group.bench_function("iter_batched_ref_large", |b| {
b.iter_batched_ref(|| vec![10], |v| v[0], BatchSize::LargeInput)
b.iter_batched_ref(|| vec![10], |v| v[0], BatchSize::LargeInput);
});
group.bench_function("iter_batched_ref_per_iteration", |b| {
b.iter_batched_ref(|| vec![10], |v| v[0], BatchSize::PerIteration)
b.iter_batched_ref(|| vec![10], |v| v[0], BatchSize::PerIteration);
});
group.bench_function("iter_batched_ref_one_batch", |b| {
b.iter_batched_ref(|| vec![10], |v| v[0], BatchSize::NumBatches(1))
b.iter_batched_ref(|| vec![10], |v| v[0], BatchSize::NumBatches(1));
});
group.bench_function("iter_batched_ref_10_iterations", |b| {
b.iter_batched_ref(|| vec![10], |v| v[0], BatchSize::NumIterations(10))
b.iter_batched_ref(|| vec![10], |v| v[0], BatchSize::NumIterations(10));
});
}

Expand Down Expand Up @@ -461,7 +461,7 @@ fn test_criterion_doesnt_panic_if_measured_time_is_zero() {
let dir = temp_dir();
let mut c = short_benchmark(&dir);
c.bench_function("zero_time", |bencher| {
bencher.iter_custom(|_iters| Duration::new(0, 0))
bencher.iter_custom(|_iters| Duration::new(0, 0));
});
}

Expand Down Expand Up @@ -494,7 +494,7 @@ mod macros {

// silence dead_code warning
if false {
main()
main();
}
}

Expand Down

0 comments on commit 3d9a9a0

Please sign in to comment.