From 1c1a8b9454fe22de1a555f03994e9dace4a03919 Mon Sep 17 00:00:00 2001 From: Trivernis Date: Fri, 3 Apr 2020 11:57:30 +0200 Subject: [PATCH] Fix optimization --- Cargo.toml | 5 ++++- src/main.rs | 7 ++++--- src/to_bench.rs | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 62c5707..576c0ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,10 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[profile.release] +opt-level = 1 + [dependencies] rayon = "1.3.0" crossbeam-channel = "0.4.2" -benchlib-rs = "0.2.2" \ No newline at end of file +benchlib-rs = "0.2.2" diff --git a/src/main.rs b/src/main.rs index 20f52cf..6544b6e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,11 +7,12 @@ use benchlib::benching::Bencher; pub fn main() { let mut bencher = Bencher::new(); bencher - .set_iterations(100000000) + .set_iterations(1000000) .print_settings() + .bench("Dry Run", || {}) .bench("Multiply to 100", || to_bench::multiply_to(100)) - .bench("Summation from 0u128 to 1000000", || { - to_bench::summation_to_1000000() + .bench("Summation from 0u128 to 1000", || { + to_bench::summation_to_1000() }) .set_iterations(1000) .print_settings() diff --git a/src/to_bench.rs b/src/to_bench.rs index 20f163c..04dd34b 100644 --- a/src/to_bench.rs +++ b/src/to_bench.rs @@ -10,9 +10,9 @@ pub fn start_stop_thread() { handle.join().unwrap(); } -pub fn summation_to_1000000() -> u128 { +pub fn summation_to_1000() -> u128 { let mut res = 0u128; - for i in 0u128..1000000 { + for i in 0u128..1000 { res += i; } res