2026-01-08 21:32:59 +00:00
|
|
|
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
|
|
|
|
use provisioning_mcp_server::{Config, ProvisioningEngine, ProvisioningTools};
|
2025-10-07 10:59:52 +01:00
|
|
|
|
|
|
|
|
fn bench_server_parsing(c: &mut Criterion) {
|
|
|
|
|
let config = Config::default();
|
|
|
|
|
let tools = ProvisioningTools::new(&config);
|
2026-01-08 21:32:59 +00:00
|
|
|
|
2025-10-07 10:59:52 +01:00
|
|
|
let test_cases = vec![
|
|
|
|
|
"Create 1 server for web hosting",
|
2026-01-08 21:32:59 +00:00
|
|
|
"Create 3 servers with 8 CPU cores for kubernetes cluster on AWS",
|
2025-10-07 10:59:52 +01:00
|
|
|
"Deploy 5 t3.large instances in us-west-2 for database cluster",
|
|
|
|
|
"Setup 2 medium servers with 4 CPU cores for local development",
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
let mut group = c.benchmark_group("server_parsing");
|
2026-01-08 21:32:59 +00:00
|
|
|
|
2025-10-07 10:59:52 +01:00
|
|
|
for case in &test_cases {
|
|
|
|
|
group.bench_with_input(
|
|
|
|
|
BenchmarkId::new("parse_description", case.len()),
|
|
|
|
|
case,
|
|
|
|
|
|b, case| {
|
2026-01-08 21:32:59 +00:00
|
|
|
b.iter(|| tools.parse_server_description(std::hint::black_box(case)));
|
2025-10-07 10:59:52 +01:00
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-01-08 21:32:59 +00:00
|
|
|
|
2025-10-07 10:59:52 +01:00
|
|
|
group.finish();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn bench_ai_status(c: &mut Criterion) {
|
|
|
|
|
let config = Config::default();
|
|
|
|
|
let tools = ProvisioningTools::new(&config);
|
2026-01-08 21:32:59 +00:00
|
|
|
|
2025-10-07 10:59:52 +01:00
|
|
|
c.bench_function("ai_status", |b| {
|
2026-01-08 21:32:59 +00:00
|
|
|
b.iter(|| tools.get_ai_status());
|
2025-10-07 10:59:52 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-08 21:32:59 +00:00
|
|
|
#[allow(clippy::field_reassign_with_default)]
|
2025-10-07 10:59:52 +01:00
|
|
|
fn bench_infrastructure_status(c: &mut Criterion) {
|
|
|
|
|
let mut config = Config::default();
|
|
|
|
|
// Use current directory to avoid path issues in tests
|
|
|
|
|
config.provisioning_path = std::env::current_dir().unwrap();
|
2026-01-08 21:32:59 +00:00
|
|
|
|
2025-10-07 10:59:52 +01:00
|
|
|
if let Ok(engine) = ProvisioningEngine::new(&config) {
|
|
|
|
|
c.bench_function("infrastructure_status", |b| {
|
|
|
|
|
b.iter(|| {
|
|
|
|
|
// This will likely fail but we're measuring the time it takes
|
|
|
|
|
let _ = engine.get_status(None, false);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-08 21:32:59 +00:00
|
|
|
criterion_group!(
|
|
|
|
|
benches,
|
|
|
|
|
bench_server_parsing,
|
|
|
|
|
bench_ai_status,
|
|
|
|
|
bench_infrastructure_status
|
|
|
|
|
);
|
|
|
|
|
criterion_main!(benches);
|