Add option to print the benchmarkers settings

master
Trivernis 5 years ago
parent be72f7d831
commit 5f201be1d8

@ -1,6 +1,6 @@
[package]
name = "benchlib-rs"
version = "0.2.0"
version = "0.2.1"
authors = ["Trivernis <trivernis@gmail.com>"]
edition = "2018"
license-file = "LICENSE"

@ -199,4 +199,15 @@ impl Bencher {
self
}
/// Prints the settings of the Bencher
pub fn print_settings(&mut self) -> &mut Self {
println!("{}{}Benchmarking Settings{}", color::Fg(color::Green), style::Framed, style::Reset);
println!("Number of iterations:\t {}", if self.iterations > 0 {self.iterations.to_string() } else { "auto".to_string() });
if self.iterations == 0 {
println!("Maximum number of iterations: {}", self.max_auto_iterations)
}
self
}
}

@ -5,7 +5,7 @@ mod tests {
use super::benching::Bencher;
#[test]
fn bencher_works() {
fn it_works() {
let mut bencher = Bencher::new();
let mut executed = false;
bencher.bench("lol", || executed = true);
@ -13,7 +13,7 @@ mod tests {
}
#[test]
fn bench_iterations() {
fn it_benches_specifically() {
let mut bencher = Bencher::new();
let mut count = 0;
bencher.set_iterations(243);
@ -22,7 +22,7 @@ mod tests {
}
#[test]
fn bench_auto() {
fn it_benches_automatically() {
let mut bencher = Bencher::new();
let mut count = 0;
bencher.set_iterations(0).set_max_iterations(1000);
@ -31,10 +31,18 @@ mod tests {
}
#[test]
fn bench_difference() {
fn it_reports_differences() {
let mut bencher = Bencher::new();
bencher.bench("lol", || 3*4);
bencher.bench("lol2", || 35*4);
bencher.compare();
}
#[test]
fn it_prints_settings() {
let mut bencher = Bencher::new();
bencher.print_settings();
bencher.set_iterations(0);
bencher.print_settings();
}
}

Loading…
Cancel
Save