Update tests, examples, benches

This commit is contained in:
TechnoPorg committed 2026-01-22 00:30:48 +01:00
1 parent bacac903b3
commit 85ccd7e507
89 files changed
+942 -1785

No files matched your search

+10 -15
View File
@@ -2,6 +2,7 @@
use criterion::Criterion;
use dagx::{task_fn, DagRunner, Task};
use futures::FutureExt;
pub fn bench_dag_execution(c: &mut Criterion) {
let rt = tokio::runtime::Runtime::new().unwrap();
@@ -13,11 +14,9 @@ pub fn bench_dag_execution(c: &mut Criterion) {
for i in 0..10 {
dag.add_task(task_fn(move |_: ()| async move { i }));
}
dag.run(|fut| {
tokio::spawn(fut);
})
.await
.unwrap();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
.unwrap();
})
});
});
@@ -29,11 +28,9 @@ pub fn bench_dag_execution(c: &mut Criterion) {
for i in 0..100 {
dag.add_task(task_fn(move |_: ()| async move { i }));
}
dag.run(|fut| {
tokio::spawn(fut);
})
.await
.unwrap();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
.unwrap();
})
});
});
@@ -111,11 +108,9 @@ pub fn bench_dag_execution(c: &mut Criterion) {
.add_task(task_fn(|x: i32| async move { x + 1 }))
.depends_on(t18);
dag.run(|fut| {
tokio::spawn(fut);
})
.await
.unwrap();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
.unwrap();
})
});
});
+4 -5
View File
@@ -2,6 +2,7 @@
use criterion::{BenchmarkId, Criterion};
use dagx::{task_fn, DagRunner};
use futures::FutureExt;
pub fn bench_dag_scaling(c: &mut Criterion) {
let rt = tokio::runtime::Runtime::new().unwrap();
@@ -18,11 +19,9 @@ pub fn bench_dag_scaling(c: &mut Criterion) {
for i in 0..size {
dag.add_task(task_fn(move |_: ()| async move { i }));
}
dag.run(|fut| {
tokio::spawn(fut);
})
.await
.unwrap();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
.unwrap();
})
});
});
+4 -5
View File
@@ -3,6 +3,7 @@
//! Long sequential chain: 100 tasks in sequence
use criterion::Criterion;
use futures::FutureExt;
pub fn bench_deep_chain(c: &mut Criterion) {
let rt = tokio::runtime::Runtime::new().unwrap();
@@ -27,11 +28,9 @@ pub fn bench_deep_chain(c: &mut Criterion) {
.depends_on(prev);
}
dag.run(|fut| {
tokio::spawn(fut);
})
.await
.unwrap();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
.unwrap();
dag.get(prev).unwrap()
})
});
+4 -5
View File
@@ -3,6 +3,7 @@
//! Classic diamond: A → B,C → D
use criterion::Criterion;
use futures::FutureExt;
pub fn bench_diamond_pattern(c: &mut Criterion) {
let rt = tokio::runtime::Runtime::new().unwrap();
@@ -27,11 +28,9 @@ pub fn bench_diamond_pattern(c: &mut Criterion) {
.add_task(task_fn(|(x, y): (i32, i32)| async move { x + y }))
.depends_on((&b, &c));
dag.run(|fut| {
tokio::spawn(fut);
})
.await
.unwrap();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
.unwrap();
dag.get(d).unwrap()
})
});
+4 -5
View File
@@ -3,6 +3,7 @@
//! Extract → Transform → Validate → Load pattern
use criterion::Criterion;
use futures::FutureExt;
pub fn bench_etl_pipeline(c: &mut Criterion) {
let rt = tokio::runtime::Runtime::new().unwrap();
@@ -66,11 +67,9 @@ pub fn bench_etl_pipeline(c: &mut Criterion) {
}))
.depends_on(validate);
dag.run(|fut| {
tokio::spawn(fut);
})
.await
.unwrap();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
.unwrap();
dag.get(load).unwrap()
})
});
+4 -5
View File
@@ -3,6 +3,7 @@
//! 10,000 independent tasks to test scaling
use criterion::Criterion;
use futures::FutureExt;
pub fn bench_large_scale(c: &mut Criterion) {
let rt = tokio::runtime::Runtime::new().unwrap();
@@ -21,11 +22,9 @@ pub fn bench_large_scale(c: &mut Criterion) {
dag.add_task(task_fn(move |_: ()| async move { i * 2 }));
}
dag.run(|fut| {
tokio::spawn(fut);
})
.await
.unwrap();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
.unwrap();
})
});
});
+4 -5
View File
@@ -3,6 +3,7 @@
//! Simple chain of tasks: A → B → C → D → E
use criterion::Criterion;
use futures::FutureExt;
pub fn bench_linear_pipeline(c: &mut Criterion) {
let rt = tokio::runtime::Runtime::new().unwrap();
@@ -30,11 +31,9 @@ pub fn bench_linear_pipeline(c: &mut Criterion) {
.add_task(task_fn(|x: i32| async move { x * 3 }))
.depends_on(d);
dag.run(|fut| {
tokio::spawn(fut);
})
.await
.unwrap();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
.unwrap();
dag.get(e).unwrap()
})
});
+4 -5
View File
@@ -3,6 +3,7 @@
//! One source task feeding 100 dependent tasks
use criterion::Criterion;
use futures::FutureExt;
pub fn bench_wide_fanout(c: &mut Criterion) {
let rt = tokio::runtime::Runtime::new().unwrap();
@@ -23,11 +24,9 @@ pub fn bench_wide_fanout(c: &mut Criterion) {
.depends_on(&source);
}
dag.run(|fut| {
tokio::spawn(fut);
})
.await
.unwrap();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
.unwrap();
})
});
});
+7 -10
View File
@@ -2,6 +2,7 @@
use criterion::Criterion;
use dagx::{task_fn, DagRunner};
use futures::FutureExt;
pub fn bench_10k_breakdown(c: &mut Criterion) {
let rt = tokio::runtime::Runtime::new().unwrap();
@@ -26,11 +27,9 @@ pub fn bench_10k_breakdown(c: &mut Criterion) {
for i in 0..10_000 {
dag.add_task(task_fn(move |_: ()| async move { i }));
}
dag.run(|fut| {
tokio::spawn(fut);
})
.await
.unwrap();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
.unwrap();
})
});
});
@@ -45,11 +44,9 @@ pub fn bench_10k_breakdown(c: &mut Criterion) {
b.iter(|| {
rt.block_on(async {
dag.run(|fut| {
tokio::spawn(fut);
})
.await
.unwrap();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
.unwrap();
})
});
});
+4 -5
View File
@@ -2,6 +2,7 @@
use criterion::Criterion;
use dagx::{task_fn, DagRunner};
use futures::FutureExt;
pub fn bench_diamond(c: &mut Criterion) {
let rt = tokio::runtime::Runtime::new().unwrap();
@@ -25,11 +26,9 @@ pub fn bench_diamond(c: &mut Criterion) {
.depends_on((&left, &right));
}
dag.run(|fut| {
tokio::spawn(fut);
})
.await
.unwrap();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
.unwrap();
})
});
});
+10 -15
View File
@@ -2,6 +2,7 @@
use criterion::Criterion;
use dagx::{task_fn, DagRunner};
use futures::FutureExt;
pub fn bench_fanout(c: &mut Criterion) {
let rt = tokio::runtime::Runtime::new().unwrap();
@@ -18,11 +19,9 @@ pub fn bench_fanout(c: &mut Criterion) {
.depends_on(&source);
}
dag.run(|fut| {
tokio::spawn(fut);
})
.await
.unwrap();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
.unwrap();
})
});
});
@@ -45,11 +44,9 @@ pub fn bench_fanout(c: &mut Criterion) {
.depends_on(&source);
}
dag.run(|fut| {
tokio::spawn(fut);
})
.await
.unwrap();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
.unwrap();
})
});
});
@@ -72,11 +69,9 @@ pub fn bench_fanout(c: &mut Criterion) {
.depends_on(&source);
}
dag.run(|fut| {
tokio::spawn(fut);
})
.await
.unwrap();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
.unwrap();
})
});
});
+4 -5
View File
@@ -2,6 +2,7 @@
use criterion::{BenchmarkId, Criterion};
use dagx::{task_fn, DagRunner};
use futures::FutureExt;
use std::collections::HashMap;
use std::hint::black_box;
@@ -51,11 +52,9 @@ pub fn bench_config_broadcast(c: &mut Criterion) {
.depends_on(&config);
}
dag.run(|fut| {
tokio::spawn(fut);
})
.await
.unwrap();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
.unwrap();
})
});
},
+2 -3
View File
@@ -2,6 +2,7 @@
use criterion::{BenchmarkId, Criterion};
use dagx::{task_fn, DagRunner};
use futures::FutureExt;
pub fn bench_etl_pipeline(c: &mut Criterion) {
let rt = tokio::runtime::Runtime::new().unwrap();
@@ -90,9 +91,7 @@ pub fn bench_etl_pipeline(c: &mut Criterion) {
))
.depends_on((&validate, &scores, &names));
dag.run(|fut| {
tokio::spawn(fut);
})
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
.unwrap();
})
+4 -5
View File
@@ -2,6 +2,7 @@
use criterion::{BenchmarkId, Criterion};
use dagx::{task_fn, DagRunner};
use futures::FutureExt;
use std::hint::black_box;
pub fn bench_memory_efficiency(c: &mut Criterion) {
@@ -38,11 +39,9 @@ pub fn bench_memory_efficiency(c: &mut Criterion) {
.depends_on(&source);
}
dag.run(|fut| {
tokio::spawn(fut);
})
.await
.unwrap();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
.unwrap();
})
});
},
+4 -5
View File
@@ -2,6 +2,7 @@
use criterion::Criterion;
use dagx::{task_fn, DagRunner};
use futures::FutureExt;
pub fn bench_mixed_patterns(c: &mut Criterion) {
let rt = tokio::runtime::Runtime::new().unwrap();
@@ -50,11 +51,9 @@ pub fn bench_mixed_patterns(c: &mut Criterion) {
.depends_on(summary);
}
dag.run(|fut| {
tokio::spawn(fut);
})
.await
.unwrap();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
.await
.unwrap();
})
});
});