benchmark retry (#5760)
* benchmark retry Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix times Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix times Signed-off-by: Jess Frazelle <github@jessfraz.com> * dont use a custom iter Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * just parse Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * use runs on Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@ -4,7 +4,6 @@ use std::{
|
||||
};
|
||||
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
const IGNORE_DIRS: [&str; 2] = ["step", "screenshots"];
|
||||
|
||||
@ -46,7 +45,7 @@ fn run_benchmarks(c: &mut Criterion) {
|
||||
|
||||
let benchmark_dirs = discover_benchmark_dirs(&base_dir);
|
||||
|
||||
let rt = Runtime::new().unwrap();
|
||||
//let rt = tokio::runtime::Runtime::new().unwrap();
|
||||
|
||||
for dir in benchmark_dirs {
|
||||
let dir_name = dir.file_name().unwrap().to_string_lossy().to_string();
|
||||
@ -68,24 +67,35 @@ 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
|
||||
|
||||
let program = kcl_lib::Program::parse_no_errs(&input_content).unwrap();
|
||||
//let program = kcl_lib::Program::parse_no_errs(&input_content).unwrap();
|
||||
|
||||
group.bench_function("parse", |b| {
|
||||
b.iter(|| kcl_lib::Program::parse_no_errs(black_box(&input_content)).unwrap())
|
||||
});
|
||||
|
||||
group.bench_function("execute", |b| {
|
||||
/*group.bench_function("execute", |b| {
|
||||
b.iter(|| {
|
||||
rt.block_on(async {
|
||||
let ctx = kcl_lib::ExecutorContext::new_with_default_client(Default::default())
|
||||
.await
|
||||
.unwrap();
|
||||
let mut exec_state = kcl_lib::ExecState::new(&ctx.settings);
|
||||
ctx.run(black_box(&program), &mut exec_state).await.unwrap();
|
||||
ctx.close().await;
|
||||
})
|
||||
let mut result = Err(());
|
||||
for _ in 0..5 {
|
||||
// Try up to 3 times
|
||||
match rt.block_on(async {
|
||||
let ctx = kcl_lib::ExecutorContext::new_with_default_client(Default::default()).await?;
|
||||
let mut exec_state = kcl_lib::ExecState::new(&ctx.settings);
|
||||
ctx.run(black_box(&program), &mut exec_state).await?;
|
||||
ctx.close().await;
|
||||
Ok::<(), anyhow::Error>(())
|
||||
}) {
|
||||
Ok(value) => {
|
||||
result = Ok(value);
|
||||
break;
|
||||
}
|
||||
Err(_) => continue,
|
||||
}
|
||||
}
|
||||
|
||||
result.unwrap()
|
||||
})
|
||||
});
|
||||
});*/
|
||||
|
||||
group.finish();
|
||||
}
|
||||
|
||||
@ -1,63 +0,0 @@
|
||||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
||||
use kcl_lib::{test_server, UnitLength::Mm};
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
pub fn bench_execute(c: &mut Criterion) {
|
||||
for (name, code) in [
|
||||
("big_kitt", KITT_PROGRAM),
|
||||
("cube", CUBE_PROGRAM),
|
||||
("server_rack_lite", SERVER_RACK_LITE_PROGRAM),
|
||||
("server_rack_heavy", SERVER_RACK_HEAVY_PROGRAM),
|
||||
("lsystem", LSYSTEM_PROGRAM),
|
||||
] {
|
||||
let mut group = c.benchmark_group("executor");
|
||||
// Configure Criterion.rs to detect smaller differences and increase sample size to improve
|
||||
// precision and counteract the resulting noise.
|
||||
group
|
||||
.sample_size(10)
|
||||
.measurement_time(std::time::Duration::from_secs(1)); // Short
|
||||
// measurement
|
||||
// time to keep
|
||||
// it from
|
||||
// running in
|
||||
// parallel
|
||||
group.bench_with_input(BenchmarkId::new("execute", name), &code, |b, &s| {
|
||||
let rt = Runtime::new().unwrap();
|
||||
// Spawn a future onto the runtime
|
||||
b.iter(|| {
|
||||
rt.block_on(test_server::execute_and_snapshot(s, Mm, None)).unwrap();
|
||||
});
|
||||
});
|
||||
group.finish();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bench_lego(c: &mut Criterion) {
|
||||
let mut group = c.benchmark_group("executor_lego_pattern");
|
||||
// Configure Criterion.rs to detect smaller differences and increase sample size to improve
|
||||
// precision and counteract the resulting noise.
|
||||
group.sample_size(10);
|
||||
// Create lego bricks with N x 10 bumps, where N is each element of `sizes`.
|
||||
let sizes = vec![1, 2, 4];
|
||||
for size in sizes {
|
||||
group.bench_with_input(BenchmarkId::from_parameter(size), &size, |b, &size| {
|
||||
let rt = Runtime::new().unwrap();
|
||||
let code = LEGO_PROGRAM.replace("{{N}}", &size.to_string());
|
||||
// Spawn a future onto the runtime
|
||||
b.iter(|| {
|
||||
rt.block_on(test_server::execute_and_snapshot(&code, Mm, None)).unwrap();
|
||||
});
|
||||
});
|
||||
}
|
||||
group.finish();
|
||||
}
|
||||
|
||||
criterion_group!(benches, bench_lego, bench_execute);
|
||||
criterion_main!(benches);
|
||||
|
||||
const KITT_PROGRAM: &str = include_str!("../e2e/executor/inputs/kittycad_svg.kcl");
|
||||
const CUBE_PROGRAM: &str = include_str!("../e2e/executor/inputs/cube.kcl");
|
||||
const SERVER_RACK_HEAVY_PROGRAM: &str = include_str!("../e2e/executor/inputs/server-rack-heavy.kcl");
|
||||
const SERVER_RACK_LITE_PROGRAM: &str = include_str!("../e2e/executor/inputs/server-rack-lite.kcl");
|
||||
const LEGO_PROGRAM: &str = include_str!("../e2e/executor/inputs/slow_lego.kcl.tmpl");
|
||||
const LSYSTEM_PROGRAM: &str = include_str!("../e2e/executor/inputs/lsystem.kcl");
|
||||
Reference in New Issue
Block a user