dag-executor 0.1.0

A production-ready DAG executor with state management and advanced patterns
Documentation
//! Benchmark: cost of constructing and validating large DAGs.
//!
//! This is a proxy for memory/build scalability — it measures how long it takes
//! to assemble and validate graphs of increasing size, which dominates the
//! per-task fixed overhead.

use std::sync::Arc;

use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use dag_executor::prelude::*;

fn build_and_validate(n: usize) -> Dag {
    let mut dag = Dag::new();
    let mut prev: Option<String> = None;
    for i in 0..n {
        let id = format!("t{i}");
        let mut t = BasicTask::new(id.clone(), |_| async { Ok(serde_json::json!(0)) });
        if let Some(p) = prev.take() {
            t = t.with_deps([p]);
        }
        prev = Some(id);
        dag.add_task(Arc::new(t)).unwrap();
    }
    dag.validate().unwrap();
    dag
}

fn bench_build(c: &mut Criterion) {
    let mut group = c.benchmark_group("dag_build");
    for n in [1000usize, 10_000] {
        group.bench_with_input(BenchmarkId::from_parameter(n), &n, |b, &n| {
            b.iter(|| {
                let dag = build_and_validate(n);
                assert_eq!(dag.len(), n);
            });
        });
    }
    group.finish();
}

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