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,11 +48,13 @@ fn main() {
} else {
let all_regressed_benches = do_all_benches(optional_args.nr_repeat_benchmarks);
if !all_regressed_benches.is_empty() {
println!(
"The following benchmarks have shown a regression {:?} times: {:?}",
optional_args.nr_repeat_benchmarks, all_regressed_benches
);
}
}
} else {
eprintln!(
r#"I can't find bench-folder-trunk and bench-folder-branch from the current directory.

View file

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