test: update tests/examples/benches
This commit is contained in:
1 parent
e4fc0b0d44
commit
72a83e29dc
47 files changed
+491
-1239
No files matched your search
@@ -1,7 +1,7 @@
|
||||
//! Memory efficiency benchmark with large data structures
|
||||
|
||||
use criterion::{BenchmarkId, Criterion};
|
||||
use dagx::{DagRunner, TaskHandle};
|
||||
use dagx::DagRunner;
|
||||
use dagx_test::task_fn;
|
||||
use std::hint::black_box;
|
||||
|
||||
@@ -10,21 +10,19 @@ pub fn bench_memory_efficiency(c: &mut Criterion) {
|
||||
let mut group = c.benchmark_group("memory_efficiency");
|
||||
|
||||
// Test with different data sizes (in MB)
|
||||
for mb_size in [1, 5, 10].iter() {
|
||||
for mb_size in [1, 10].iter() {
|
||||
group.bench_with_input(
|
||||
BenchmarkId::new("large_data_20_consumers", format!("{}MB", mb_size)),
|
||||
mb_size,
|
||||
|b, &mb| {
|
||||
b.iter(|| {
|
||||
rt.block_on(async {
|
||||
let dag = DagRunner::new();
|
||||
let mut dag = DagRunner::new();
|
||||
|
||||
let source: TaskHandle<_> = dag
|
||||
.add_task(task_fn::<(), _, _>(move |_: ()| {
|
||||
// Create MB of data - framework wraps in Arc automatically
|
||||
vec![0u8; mb * 1024 * 1024]
|
||||
}))
|
||||
.into();
|
||||
let source = dag.add_task(task_fn::<(), _, _>(move |_: ()| {
|
||||
// Create MB of data - framework wraps in Arc automatically
|
||||
vec![0u8; mb * 1024 * 1024]
|
||||
}));
|
||||
|
||||
// 20 consumers share the data via automatic Arc wrapping
|
||||
for i in 0..20 {
|
||||
@@ -41,7 +39,8 @@ pub fn bench_memory_efficiency(c: &mut Criterion) {
|
||||
.depends_on(source);
|
||||
}
|
||||
|
||||
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
|
||||
let _output = dag
|
||||
.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
|
||||
.await
|
||||
.unwrap();
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user