diff --git a/collector/benchmarks/deeply-nested/Cargo.lock b/collector/benchmarks/deeply-nested/Cargo.lock new file mode 100644 index 000000000..578e8faa2 --- /dev/null +++ b/collector/benchmarks/deeply-nested/Cargo.lock @@ -0,0 +1,4 @@ +[[package]] +name = "deeply-nested" +version = "0.1.0" + diff --git a/collector/benchmarks/deeply-nested/Cargo.toml b/collector/benchmarks/deeply-nested/Cargo.toml new file mode 100644 index 000000000..bfc21c107 --- /dev/null +++ b/collector/benchmarks/deeply-nested/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "deeply-nested" +version = "0.1.0" +authors = ["Tatsuyuki Ishi "] + +[dependencies] diff --git a/collector/benchmarks/deeply-nested/src/lib.rs b/collector/benchmarks/deeply-nested/src/lib.rs new file mode 100644 index 000000000..25dc908ed --- /dev/null +++ b/collector/benchmarks/deeply-nested/src/lib.rs @@ -0,0 +1,26 @@ +// A test case from rust-lang/rust#38528. +// The original blowup had both exponential compute and memory complexity. +// The nesting should be kept at 16 level to avoid crashing the test machine. + +pub fn foo() -> Box> { + use std::iter::empty; + + Box::new(empty() + .chain(empty()) + .chain(empty()) + .chain(empty()) + .chain(empty()) + .chain(empty()) + .chain(empty()) + .chain(empty()) + .chain(empty()) + .chain(empty()) + .chain(empty()) // 10th .chain(empty()) + .chain(empty()) + .chain(empty()) + .chain(empty()) + .chain(empty()) + .chain(empty()) + .chain(empty()) // 16th .chain(empty()) + ) +}