Skip to content

Commit 55d6f03

Browse files
Merge pull request #185 from ishitatsuyuki/issue-38528
Add benchmark for deeply nested types
2 parents 3a5b083 + cce9f5a commit 55d6f03

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

collector/benchmarks/deeply-nested/Cargo.lock

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "deeply-nested"
3+
version = "0.1.0"
4+
authors = ["Tatsuyuki Ishi <[email protected]>"]
5+
6+
[dependencies]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// A test case from rust-lang/rust#38528.
2+
// The original blowup had both exponential compute and memory complexity.
3+
// The nesting should be kept at 16 level to avoid crashing the test machine.
4+
5+
pub fn foo() -> Box<Iterator<Item = ()>> {
6+
use std::iter::empty;
7+
8+
Box::new(empty()
9+
.chain(empty())
10+
.chain(empty())
11+
.chain(empty())
12+
.chain(empty())
13+
.chain(empty())
14+
.chain(empty())
15+
.chain(empty())
16+
.chain(empty())
17+
.chain(empty())
18+
.chain(empty()) // 10th .chain(empty())
19+
.chain(empty())
20+
.chain(empty())
21+
.chain(empty())
22+
.chain(empty())
23+
.chain(empty())
24+
.chain(empty()) // 16th .chain(empty())
25+
)
26+
}

0 commit comments

Comments
 (0)