difftreelog
perf use mimalloc in benches
in: master
1 file changed
tests/benches/cpp_test_suite.rsdiffbeforeafterboth3use criterion::{Criterion, criterion_group, criterion_main};3use criterion::{Criterion, criterion_group, criterion_main};4use jrsonnet_evaluator::{4use jrsonnet_evaluator::{5 FileImportResolver, State, apply_tla, manifest::JsonFormat, trace::PathResolver,5 FileImportResolver, State, apply_tla,6 manifest::{BlackBoxFormat, JsonFormat},7 stack::limit_stack_depth,8 trace::PathResolver,6};9};1011#[global_allocator]12static GLOBAL: mimallocator::Mimalloc = mimallocator::Mimalloc;7138fn bench_entry(c: &mut Criterion, path: &Path) {14fn bench_entry(c: &mut Criterion, path: &Path) {9 c.bench_function(15 c.bench_function(12 .to_str()18 .to_str()13 .expect("name is utf-8"),19 .expect("name is utf-8"),14 |b| {20 |b| {21 let _stack = limit_stack_depth(200_000);2215 let mut s = State::builder();23 let mut s = State::builder();162425 b.iter(|| {33 b.iter(|| {26 let imported = s.import(path).expect("evaluated");34 let imported = s.import(path).expect("evaluated");27 let res = apply_tla(&HashMap::new(), imported).expect("tla applied");35 let res = apply_tla(&HashMap::new(), imported).expect("tla applied");28 black_box(res.manifest(JsonFormat::cli(3)))36 black_box(res.manifest(JsonFormat::cli(3)).expect("manifested"));29 });37 });30 },38 },31 );39 );43 }51 }44 for entry in read_dir("cpp_benchmarks").expect("dir exists") {52 for entry in read_dir("cpp_benchmarks").expect("dir exists") {45 let entry = entry.expect("entry is valid");53 let entry = entry.expect("entry is valid");46 // Skip .gitignore47 if entry.path().extension().is_none() {54 if entry.path().extension().is_none_or(|e| e != "jsonnet") {48 continue;55 continue;49 }56 }50 assert!(entry.metadata().expect("entry is valid").is_file());57 assert!(entry.metadata().expect("entry is valid").is_file());