//! Criterion benches against the performance targets in spec §9.
//!
//! Status: stub for milestone 0.1 — we measure `subdivide_all` on a
//! single block and on a 10x10 grid. The 100/10000-block targets
//! land in milestone 0.2.

#![allow(missing_docs)] // criterion_group! generates undocumented items

use criterion::{criterion_group, criterion_main, Criterion};
use glam::DVec2;
use road_parceling::{subdivide_all, RoadGraph, SubdivisionParams};

fn rectangle_graph(w: f64, h: f64) -> RoadGraph {
    let mut g = RoadGraph::new();
    let a = g.add_node(DVec2::new(0.0, 0.0));
    let b = g.add_node(DVec2::new(w, 0.0));
    let c = g.add_node(DVec2::new(w, h));
    let d = g.add_node(DVec2::new(0.0, h));
    g.add_road(a, b).unwrap();
    g.add_road(b, c).unwrap();
    g.add_road(c, d).unwrap();
    g.add_road(d, a).unwrap();
    g.rebuild_topology().unwrap();
    g
}

fn bench_one_block(c: &mut Criterion) {
    let g = rectangle_graph(200.0, 100.0);
    let params = SubdivisionParams::default();
    c.bench_function("subdivide_one_rectangle", |b| {
        b.iter(|| subdivide_all(&g, &params).unwrap());
    });
}

criterion_group!(benches, bench_one_block);
criterion_main!(benches);
