put execution benchmarks behind flag (#6364)

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2025-04-16 21:23:30 -07:00
committed by GitHub
parent ac75181f7f
commit be119248a6
3 changed files with 5 additions and 2 deletions

View File

@ -105,6 +105,7 @@ tower-lsp = { workspace = true, features = ["proposed", "default"] }
[features]
default = ["cli", "engine"]
benchmark-execution = []
cli = ["dep:clap", "kittycad/clap"]
dhat-heap = ["dep:dhat"]
# For the lsp server, when run with stdout for rpc we want to disable println.

View File

@ -45,6 +45,7 @@ fn run_benchmarks(c: &mut Criterion) {
let benchmark_dirs = discover_benchmark_dirs(&base_dir);
#[cfg(feature = "benchmark-execution")]
let rt = tokio::runtime::Runtime::new().unwrap();
for dir in benchmark_dirs {
@ -67,12 +68,14 @@ fn run_benchmarks(c: &mut Criterion) {
.sample_size(10)
.measurement_time(std::time::Duration::from_secs(1)); // Short measurement time to keep it from running in parallel
#[cfg(feature = "benchmark-execution")]
let program = kcl_lib::Program::parse_no_errs(&input_content).unwrap();
group.bench_function(format!("parse_{}", dir_name), |b| {
b.iter(|| kcl_lib::Program::parse_no_errs(black_box(&input_content)).unwrap())
});
#[cfg(feature = "benchmark-execution")]
group.bench_function(format!("execute_{}", dir_name), |b| {
b.iter(|| {
if let Err(err) = rt.block_on(async {