feat dedup Tera renderer; update logging

This commit is contained in:
2026-02-26 02:00:11 -07:00
parent f8ced2196c
commit d8134095ab
7 changed files with 303 additions and 111 deletions

View File

@@ -1,28 +1,46 @@
use criterion::{Criterion, criterion_group, criterion_main};
use skyforge::log::{LOG_LEVEL, LogLevel};
use skyforge::{Args, DeviceConfigBundle, Specification};
use std::path::PathBuf;
fn env() -> skyforge::cli::EnvVars {
skyforge::cli::EnvVars {
spec_path: PathBuf::from("./demo/spec"),
tmpl_path: PathBuf::from("./demo/tmpl"),
out_path: PathBuf::from("./demo/out"),
log_path: PathBuf::from("./demo/log"),
}
}
fn benchmark(c: &mut Criterion) {
LOG_LEVEL.set(LogLevel::Warning).ok();
let args = Args {
devices: regex::Regex::new(".*").unwrap(),
env: skyforge::cli::EnvVars {
spec_path: PathBuf::from("./demo/spec"),
tmpl_path: PathBuf::from("./demo/tmpl"),
out_path: PathBuf::from("./demo/out"),
log_path: PathBuf::from("./demo/log"),
},
classic: false,
env: env(),
};
c.bench_function("compile", |b| {
c.bench_function("process_specs", |b| {
b.iter(|| {
for spec in Specification::compile(&args) {
DeviceConfigBundle::from_spec(spec)
.unwrap()
.output_artifacts();
}
})
DeviceConfigBundle::process_specs(Specification::compile(&args)).unwrap();
});
});
}
criterion_group!(benches, benchmark);
fn benchmark_classic(c: &mut Criterion) {
LOG_LEVEL.set(LogLevel::Warning).ok();
let args = Args {
devices: regex::Regex::new(".*").unwrap(),
classic: true,
env: env(),
};
c.bench_function("from_spec", |b| {
b.iter(|| {
for spec in Specification::compile(&args) {
DeviceConfigBundle::from_spec(spec).unwrap();
}
});
});
}
criterion_group!(benches, benchmark, benchmark_classic);
criterion_main!(benches);