refactor: consolidate some tests/examples/benchmarks
This commit is contained in:
1 parent
49be497964
commit
b8204c4ed9
83 files changed
+569
-10068
No files matched your search
@@ -1,6 +1,6 @@
|
||||
//! 10,000 task breakdown benchmarks - construction vs execution
|
||||
|
||||
use criterion::Criterion;
|
||||
use criterion::{BatchSize, Criterion};
|
||||
use dagx::{task_fn, DagRunner};
|
||||
|
||||
pub fn bench_10k_breakdown(c: &mut Criterion) {
|
||||
@@ -35,19 +35,23 @@ pub fn bench_10k_breakdown(c: &mut Criterion) {
|
||||
|
||||
// c) Execution only (pre-built DAG, just run)
|
||||
group.bench_function("execution_only", |b| {
|
||||
// Pre-build the DAG outside the measurement
|
||||
let dag = DagRunner::new();
|
||||
for i in 0..10_000 {
|
||||
dag.add_task(task_fn::<(), _, _>(move |_: ()| i));
|
||||
}
|
||||
|
||||
b.iter(|| {
|
||||
rt.block_on(async {
|
||||
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
|
||||
.await
|
||||
.unwrap();
|
||||
})
|
||||
});
|
||||
b.iter_batched(
|
||||
|| {
|
||||
let dag = DagRunner::new();
|
||||
for i in 0..10_000 {
|
||||
dag.add_task(task_fn::<(), _, _>(move |_: ()| i));
|
||||
}
|
||||
dag
|
||||
},
|
||||
|dag| {
|
||||
rt.block_on(async {
|
||||
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
|
||||
.await
|
||||
.unwrap();
|
||||
})
|
||||
},
|
||||
BatchSize::LargeInput,
|
||||
);
|
||||
});
|
||||
|
||||
group.finish();
|
||||
|
||||
@@ -51,30 +51,4 @@ pub fn bench_fanout(c: &mut Criterion) {
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
// Arc overhead benchmark - shows cost on Copy types
|
||||
// For Copy types like usize, Arc adds overhead (atomic refcounting + indirection)
|
||||
// For heap types like Vec, Arc overhead is negligible compared to clone cost
|
||||
c.bench_function("arc_overhead_copy_type", |b| {
|
||||
b.iter(|| {
|
||||
rt.block_on(async {
|
||||
let dag = DagRunner::new();
|
||||
|
||||
// Source produces a simple Copy type (usize)
|
||||
// Framework wraps in Arc<usize> internally
|
||||
let source: TaskHandle<_> =
|
||||
dag.add_task(task_fn::<(), _, _>(|_: ()| 42usize)).into();
|
||||
|
||||
// 100 dependents - Arc overhead visible on Copy types
|
||||
for i in 0..100 {
|
||||
dag.add_task(task_fn::<usize, _, _>(move |x: &usize| x + i))
|
||||
.depends_on(source);
|
||||
}
|
||||
|
||||
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
|
||||
.await
|
||||
.unwrap();
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user