ftm, nicer print

This commit is contained in:
Anton-4 2021-08-03 13:44:56 +02:00
parent ca060f4295
commit 98fc155faf
2 changed files with 23 additions and 22 deletions

View file

@ -48,10 +48,12 @@ fn main() {
} else { } else {
let all_regressed_benches = do_all_benches(optional_args.nr_repeat_benchmarks); let all_regressed_benches = do_all_benches(optional_args.nr_repeat_benchmarks);
println!( if !all_regressed_benches.is_empty() {
"The following benchmarks have shown a regression {:?} times: {:?}", println!(
optional_args.nr_repeat_benchmarks, all_regressed_benches "The following benchmarks have shown a regression {:?} times: {:?}",
); optional_args.nr_repeat_benchmarks, all_regressed_benches
);
}
} }
} else { } else {
eprintln!( eprintln!(

View file

@ -1,6 +1,6 @@
use crate::helpers::{example_file, run_cmd, run_roc}; use crate::helpers::{example_file, run_cmd, run_roc};
use criterion::{black_box, measurement::Measurement, BenchmarkGroup}; use criterion::{black_box, measurement::Measurement, BenchmarkGroup};
use rlimit::{Resource, setrlimit}; use rlimit::{setrlimit, Resource};
use std::path::Path; use std::path::Path;
fn exec_bench_w_input<T: Measurement>( fn exec_bench_w_input<T: Measurement>(
@ -35,17 +35,17 @@ fn check_cmd_output(
executable_filename: &str, executable_filename: &str,
expected_ending: &str, expected_ending: &str,
) { ) {
let cmd_str = file.with_file_name(executable_filename).to_str().unwrap().to_string(); let cmd_str = file
.with_file_name(executable_filename)
.to_str()
.unwrap()
.to_string();
if cmd_str.contains("cfold") { if cmd_str.contains("cfold") {
increase_stack_limit(); increase_stack_limit();
} }
let out = run_cmd( let out = run_cmd(&cmd_str, &[stdin_str], &[]);
&cmd_str,
&[stdin_str],
&[],
);
if !&out.stdout.ends_with(expected_ending) { if !&out.stdout.ends_with(expected_ending) {
panic!( panic!(
@ -62,21 +62,19 @@ fn bench_cmd<T: Measurement>(
executable_filename: &str, executable_filename: &str,
bench_group_opt: Option<&mut BenchmarkGroup<T>>, bench_group_opt: Option<&mut BenchmarkGroup<T>>,
) { ) {
let cmd_str = file.with_file_name(executable_filename).to_str().unwrap().to_string(); let cmd_str = file
.with_file_name(executable_filename)
.to_str()
.unwrap()
.to_string();
if cmd_str.contains("cfold") { if cmd_str.contains("cfold") {
increase_stack_limit(); increase_stack_limit();
} }
if let Some(bench_group) = bench_group_opt { if let Some(bench_group) = bench_group_opt {
bench_group.bench_function(&format!("Benchmarking {:?}", executable_filename), |b| { bench_group.bench_function(&format!("Benchmarking {:?}", executable_filename), |b| {
b.iter(|| { b.iter(|| run_cmd(black_box(&cmd_str), black_box(&[stdin_str]), &[]))
run_cmd(
black_box(&cmd_str),
black_box(&[stdin_str]),
&[],
)
})
}); });
} else { } else {
run_cmd( run_cmd(
@ -88,8 +86,9 @@ fn bench_cmd<T: Measurement>(
} }
fn increase_stack_limit() { fn increase_stack_limit() {
let new_stack_limit = 8192*100000; let new_stack_limit = 8192 * 100000;
setrlimit(Resource::STACK, new_stack_limit, new_stack_limit).expect("Failed to increase stack limit."); setrlimit(Resource::STACK, new_stack_limit, new_stack_limit)
.expect("Failed to increase stack limit.");
} }
pub fn bench_nqueens<T: Measurement>(bench_group_opt: Option<&mut BenchmarkGroup<T>>) { pub fn bench_nqueens<T: Measurement>(bench_group_opt: Option<&mut BenchmarkGroup<T>>) {