diff --git a/Cargo.toml b/Cargo.toml index d072ab8..5360ea7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "benchlib-rs" -version = "0.3.0" +version = "0.3.1" authors = ["Trivernis "] edition = "2018" license-file = "LICENSE" diff --git a/src/benching.rs b/src/benching.rs index 226f62c..3f0395f 100644 --- a/src/benching.rs +++ b/src/benching.rs @@ -195,7 +195,12 @@ impl Bencher { for _ in 0..self.iterations { let start = Instant::now(); func(); - durations.push(start.elapsed()); + let duration = start.elapsed(); + if duration > self.bench_duration { + durations.push(duration - self.bench_duration); + } else { + durations.push(duration); + } } } println!("Result: {}", durations);