Skip to content
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

Add a new const eval perf problem to the test suite #349

Merged
merged 2 commits into from
Feb 21, 2019
Merged
Show file tree
Hide file tree
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[package]
name = "ctfe-stress"
name = "ctfe-stress-2"
version = "0.1.0"
authors = ["Ralf Jung <post@ralfj.de>"]
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// And without support for loops.

macro_rules! const_repeat {
// Base case: Use 16 at the end to avoid function calls at the leaves as much as possibele.
// Base case: Use 16 at the end to avoid function calls at the leafs as much as possible.
([16] $e: expr, $T: ty) => {{
$e; $e; $e; $e;
$e; $e; $e; $e;
Expand Down Expand Up @@ -60,3 +60,8 @@ expensive_static!(OPS: i32 = ((((10 >> 1) + 3) * 7) / 2 - 12) << 4; [4 16 16 16
expensive_static!(RELOCATIONS : &'static str = "hello"; [8 16 16 16 16]);
expensive_static!(UNSIZE_SLICE: &'static [u8] = b"foo"; [4 16 16 16 16 16]);
expensive_static!(UNSIZE_TRAIT: &'static Trait = &42u32; [4 16 16 16 16 16]);

// copying all these zeros and the corresponding definedness bits can be expensive and is probably
// prone to regressions.
// 24 is an exponent that makes the repeat expression take less than two seconds to compute
const FOO: [i32; 1 << 24] = [0; 1 << 24];
Copy link
Member

@RalfJung RalfJung Oct 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried hard to give more or less reasonable names to the constants above; I think we can do better than FOO ;)