From a4efef23821fd26951b4e3db2504fdcd2d3595ad Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Wed, 10 Jan 2024 21:24:00 +0100 Subject: [PATCH] cargo fmt --- members/criterion_ex/src/lib.rs | 2 +- members/revsqrt/benches/rsqrt-bench.rs | 53 +++++++++++++++++++------- src/main.rs | 5 ++- 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/members/criterion_ex/src/lib.rs b/members/criterion_ex/src/lib.rs index 0472deb..8fea0cd 100644 --- a/members/criterion_ex/src/lib.rs +++ b/members/criterion_ex/src/lib.rs @@ -3,6 +3,6 @@ pub fn fibonacci(n: u64) -> u64 { match n { 0 => 1, 1 => 1, - n => fibonacci(n-1) + fibonacci(n-2), + n => fibonacci(n - 1) + fibonacci(n - 2), } } diff --git a/members/revsqrt/benches/rsqrt-bench.rs b/members/revsqrt/benches/rsqrt-bench.rs index 5982390..1036b98 100644 --- a/members/revsqrt/benches/rsqrt-bench.rs +++ b/members/revsqrt/benches/rsqrt-bench.rs @@ -1,31 +1,58 @@ #![allow(unused)] -use criterion::{black_box, criterion_group, criterion_main, Criterion, BenchmarkId, Throughput}; -use revsqrt::{inverse_sqrt, fast_inverse_sqrt}; +use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; +use revsqrt::{fast_inverse_sqrt, inverse_sqrt}; const SIZE: f32 = 1337.1337; const FCONST: f32 = 1024.12481224; const FCONST1: f32 = 4025.724812234; pub fn single_input(c: &mut Criterion) { - c.bench_with_input(BenchmarkId::new("regular rsqrt", SIZE),&SIZE, |b, &s| b.iter(|| inverse_sqrt(s))); - c.bench_with_input(BenchmarkId::new("fast rsqrt", SIZE),&SIZE, |b, &s| b.iter(|| fast_inverse_sqrt(s))); + c.bench_with_input(BenchmarkId::new("regular rsqrt", SIZE), &SIZE, |b, &s| { + b.iter(|| inverse_sqrt(s)) + }); + c.bench_with_input(BenchmarkId::new("fast rsqrt", SIZE), &SIZE, |b, &s| { + b.iter(|| fast_inverse_sqrt(s)) + }); } pub fn multi_input(c: &mut Criterion) { let mut group = c.benchmark_group("multi_input"); - for size in [FCONST, 2.2 * FCONST, 4.24 * FCONST, 8.64 * FCONST, 16.12 * FCONST].iter() { + for size in [ + FCONST, + 2.2 * FCONST, + 4.24 * FCONST, + 8.64 * FCONST, + 16.12 * FCONST, + ] + .iter() + { group.throughput(Throughput::Bytes(*size as u64)); - group.bench_with_input(BenchmarkId::new("regular rsqrt mixed input", FCONST), size, |b, &size| { - b.iter(||inverse_sqrt(size)); - }); + group.bench_with_input( + BenchmarkId::new("regular rsqrt mixed input", FCONST), + size, + |b, &size| { + b.iter(|| inverse_sqrt(size)); + }, + ); } - for size in [FCONST1, 2.2 * FCONST1, 4.24 * FCONST1, 8.64 * FCONST1, 16.12 * FCONST1].iter() { + for size in [ + FCONST1, + 2.2 * FCONST1, + 4.24 * FCONST1, + 8.64 * FCONST1, + 16.12 * FCONST1, + ] + .iter() + { group.throughput(Throughput::Bytes(*size as u64)); - group.bench_with_input(BenchmarkId::new("fast rsqrt mixed input", FCONST1), size, |b, &size| { - b.iter(||fast_inverse_sqrt(size)); - }); + group.bench_with_input( + BenchmarkId::new("fast rsqrt mixed input", FCONST1), + size, + |b, &size| { + b.iter(|| fast_inverse_sqrt(size)); + }, + ); } group.finish(); } - criterion_group!(benches, single_input, multi_input); criterion_main!(benches); diff --git a/src/main.rs b/src/main.rs index c19ca67..9281f5c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ fn main() { println!( -"SUCCESS!!! + "SUCCESS!!! This is the default executable! It does not do much, use another executable. Select your target like this: @@ -8,5 +8,6 @@ Select your target like this: To see a list of all runnable binaries, you can use the following command. `cargo run --bin` -"); +" + ); }