From edb8e7e9a32908841d545ba54576d63e39afffbb Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Sun, 05 Apr 2026 00:05:42 +0000 Subject: [PATCH] perf: use mimalloc in benches --- --- a/tests/benches/cpp_test_suite.rs +++ b/tests/benches/cpp_test_suite.rs @@ -2,9 +2,15 @@ use criterion::{Criterion, criterion_group, criterion_main}; use jrsonnet_evaluator::{ - FileImportResolver, State, apply_tla, manifest::JsonFormat, trace::PathResolver, + FileImportResolver, State, apply_tla, + manifest::{BlackBoxFormat, JsonFormat}, + stack::limit_stack_depth, + trace::PathResolver, }; +#[global_allocator] +static GLOBAL: mimallocator::Mimalloc = mimallocator::Mimalloc; + fn bench_entry(c: &mut Criterion, path: &Path) { c.bench_function( path.file_name() @@ -12,6 +18,8 @@ .to_str() .expect("name is utf-8"), |b| { + let _stack = limit_stack_depth(200_000); + let mut s = State::builder(); s.context_initializer(jrsonnet_stdlib::ContextInitializer::new( @@ -25,7 +33,7 @@ b.iter(|| { let imported = s.import(path).expect("evaluated"); let res = apply_tla(&HashMap::new(), imported).expect("tla applied"); - black_box(res.manifest(JsonFormat::cli(3))) + black_box(res.manifest(JsonFormat::cli(3)).expect("manifested")); }); }, ); @@ -43,8 +51,7 @@ } for entry in read_dir("cpp_benchmarks").expect("dir exists") { let entry = entry.expect("entry is valid"); - // Skip .gitignore - if entry.path().extension().is_none() { + if entry.path().extension().is_none_or(|e| e != "jsonnet") { continue; } assert!(entry.metadata().expect("entry is valid").is_file()); -- gitstuff