Skip to content

Migrate ctfe-stress-test-3 to ctfe-stress-test-4 #552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions collector/benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -71,7 +71,7 @@ programs.
- **coercions**: Contains a static array with 65,536 string literals, which
caused [poor performance](https://github.com/rust-lang/rust/issues/32278) in
the past.
- **ctfe-stress-3**: A stress test for compile-time function evaluation.
- **ctfe-stress-4**: A stress test for compile-time function evaluation.
- **deeply-nested**: A small program that caused [exponential
behavior](https://github.com/rust-lang/rust/issues/38528) in the past.
- **deep-vector**: A test containing a single large vector of zeroes, which
@@ -94,4 +94,3 @@ programs.
behavior](https://github.com/rust-lang/rust/pull/32062) in the past.
- **unused-warnings**: Contains many unused imports, which caused [quadratic
behavior](https://github.com/rust-lang/rust/issues/43572) in the past.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[package]
name = "ctfe-stress-3"
name = "ctfe-stress-4"
version = "0.1.0"
authors = ["Ralf Jung <[email protected]>"]
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@
use std::mem::MaybeUninit;

// Try to make CTFE actually do a lot of computation, without producing a big result.
// The const fn expressions evaluated here take a dummy u32 argument because otherwise
// const fn memoisation is able to eliminate a lot of the work.
// And without support for loops.

macro_rules! const_repeat {
@@ -17,27 +19,27 @@ macro_rules! const_repeat {
}};
// Recursive case: Take a 16
([16 $($n: tt)*] $e: expr, $T: ty) => {{
const fn e() -> $T { const_repeat!([$($n)*] $e, $T) }
e(); e(); e(); e();
e(); e(); e(); e();
e(); e(); e(); e();
e(); e(); e(); e()
const fn e(_: u32) -> $T { const_repeat!([$($n)*] $e, $T) }
e(0); e(0); e(0); e(0);
e(0); e(0); e(0); e(0);
e(0); e(0); e(0); e(0);
e(0); e(0); e(0); e(0)
}};
// Recursive case: Take a 8
([8 $($n: tt)*] $e: expr, $T: ty) => {{
const fn e() -> $T { const_repeat!([$($n)*] $e, $T) }
e(); e(); e(); e();
e(); e(); e(); e()
const fn e(_: u32) -> $T { const_repeat!([$($n)*] $e, $T) }
e(0); e(0); e(0); e(0);
e(0); e(0); e(0); e(0)
}};
// Recursive case: Take a 4
([4 $($n: tt)*] $e: expr, $T: ty) => {{
const fn e() -> $T { const_repeat!([$($n)*] $e, $T) }
e(); e(); e(); e()
const fn e(_: u32) -> $T { const_repeat!([$($n)*] $e, $T) }
e(0); e(0); e(0); e(0)
}};
// Recursive case: Take a 2
([2 $($n: tt)*] $e: expr, $T: ty) => {{
const fn e() -> $T { const_repeat!([$($n)*] $e, $T) }
e(); e()
const fn e(_: u32) -> $T { const_repeat!([$($n)*] $e, $T) }
e(0); e(0)
}};
}
macro_rules! expensive_static {