use divan::AllocProfiler;
use divan::black_box;
use knot_static::nginx::conf::{Block, NONE};
#[global_allocator]
static ALLOC: AllocProfiler = AllocProfiler::system();
fn main() {
divan::main();
}
fn tree(locations: usize) -> Block {
Block::new("server", NONE).blocks((0..locations).map(|n| {
Block::exact(format!("/repo-{n}/info/refs"))
.directive(
"default_type",
["application/x-git-upload-pack-advertisement"],
)
.directive("add_header", ["Cache-Control", "public, max-age=60"])
}))
}
#[divan::bench(args = [10, 1_000])]
fn render(bencher: divan::Bencher, locations: usize) {
let block = tree(locations);
bencher.bench_local(|| black_box(&block).to_string());
}