Fix benchmark compilation + add super deep benchmarks (#255)
* Fix benchmark compilation + add super deep benchmarks
* cargo fmt
b2046b1207bcf5a035e4397fb05a20b75f8eff42 · by Nico Burns · (3 years ago) · parent dfaec22a1 · browse the tree at this commit
diff --git a/benches/big_tree.rs b/benches/big_tree.rs
index d965885ac..12154205a 100644
--- a/benches/big_tree.rs
+++ b/benches/big_tree.rs
@@ -203,6 +203,23 @@ fn taffy_benchmarks(c: &mut Criterion) {
b.iter(|| taffy.compute_layout(root, Size::MAX_CONTENT).unwrap())
});
+
+ drop(group);
+
+ let mut group = c.benchmark_group("super deep trees");
+ group.sample_size(10);
+
+ group.bench_function("100 nodes (100-level hierarchy)", |b| {
+ let mut taffy = Taffy::new();
+ let root = build_yoga_deep_hierarchy(&mut taffy, 100, 1);
+ b.iter(|| taffy.compute_layout(root, Size::MAX_CONTENT).unwrap())
+ });
+
+ group.bench_function("1_000 nodes (1000-level hierarchy)", |b| {
+ let mut taffy = Taffy::new();
+ let root = build_yoga_deep_hierarchy(&mut taffy, 1_000, 1);
+ b.iter(|| taffy.compute_layout(root, Size::MAX_CONTENT).unwrap())
+ });
}
criterion_group!(benches, taffy_benchmarks);
diff --git a/benches/complex.rs b/benches/complex.rs
index 4ba4945c3..ad7493b14 100644
--- a/benches/complex.rs
+++ b/benches/complex.rs
@@ -1,4 +1,5 @@
use criterion::{criterion_group, criterion_main, Criterion};
+use taffy::tree::LayoutTree;
fn build_deep_hierarchy(taffy: &mut taffy::node::Taffy) -> taffy::node::Node {
let node111 = taffy