Skip to content

add CTFE stress test #266

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 2 commits into from
Aug 9, 2018
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
4 changes: 4 additions & 0 deletions collector/benchmarks/ctfe-stress-cast/Cargo.lock

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

4 changes: 4 additions & 0 deletions collector/benchmarks/ctfe-stress-cast/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
name = "ctfe-stress"
version = "0.1.0"
authors = ["Ralf Jung <post@ralfj.de>"]
42 changes: 42 additions & 0 deletions collector/benchmarks/ctfe-stress-cast/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#![feature(const_fn, const_let)]
#![allow(unused_must_use)]

// Try to make CTFE actually do a lot of computation, without producing a big result.
// 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.
([16] $e: expr, $T: ty) => {{
$e; $e; $e; $e;
$e; $e; $e; $e;
$e; $e; $e; $e;
$e; $e; $e; $e
}};
([1] $e: expr, $T: ty) => {{
$e
}};
// 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()
}};
// 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()
}};
// Recursive case: Take a 2
([2 $($n: tt)*] $e: expr, $T: ty) => {{
const fn e() -> $T { const_repeat!([$($n)*] $e, $T) }
e(); e()
}};
}
macro_rules! expensive_static {
($name: ident : $T: ty = $e : expr) =>
(pub static $name : $T = const_repeat!([2 16 16 16 16 16] $e, $T);)
}

expensive_static!(CHAIN: usize = 42i32 as u8 as u64 as i8 as isize as usize);
4 changes: 4 additions & 0 deletions collector/benchmarks/ctfe-stress-const-fn/Cargo.lock

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

4 changes: 4 additions & 0 deletions collector/benchmarks/ctfe-stress-const-fn/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
name = "ctfe-stress"
version = "0.1.0"
authors = ["Ralf Jung <post@ralfj.de>"]
44 changes: 44 additions & 0 deletions collector/benchmarks/ctfe-stress-const-fn/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#![feature(const_fn, const_let)]
#![allow(unused_must_use)]

// Try to make CTFE actually do a lot of computation, without producing a big result.
// 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.
([16] $e: expr, $T: ty) => {{
$e; $e; $e; $e;
$e; $e; $e; $e;
$e; $e; $e; $e;
$e; $e; $e; $e
}};
([1] $e: expr, $T: ty) => {{
$e
}};
// 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()
}};
// 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()
}};
// Recursive case: Take a 2
([2 $($n: tt)*] $e: expr, $T: ty) => {{
const fn e() -> $T { const_repeat!([$($n)*] $e, $T) }
e(); e()
}};
}
macro_rules! expensive_static {
($name: ident : $T: ty = $e : expr) =>
(pub static $name : $T = const_repeat!([2 16 16 16 16 16] $e, $T);)
}

const fn inc(i: i32) -> i32 { i + 1 }

expensive_static!(CONST_FN_SIMPLE: i32 = inc(42));
4 changes: 4 additions & 0 deletions collector/benchmarks/ctfe-stress-force-alloc/Cargo.lock

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

4 changes: 4 additions & 0 deletions collector/benchmarks/ctfe-stress-force-alloc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
name = "ctfe-stress"
version = "0.1.0"
authors = ["Ralf Jung <post@ralfj.de>"]
42 changes: 42 additions & 0 deletions collector/benchmarks/ctfe-stress-force-alloc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#![feature(const_fn, const_let)]
#![allow(unused_must_use)]

// Try to make CTFE actually do a lot of computation, without producing a big result.
// 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.
([16] $e: expr, $T: ty) => {{
$e; $e; $e; $e;
$e; $e; $e; $e;
$e; $e; $e; $e;
$e; $e; $e; $e
}};
([1] $e: expr, $T: ty) => {{
$e
}};
// 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()
}};
// 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()
}};
// Recursive case: Take a 2
([2 $($n: tt)*] $e: expr, $T: ty) => {{
const fn e() -> $T { const_repeat!([$($n)*] $e, $T) }
e(); e()
}};
}
macro_rules! expensive_static {
($name: ident : $T: ty = $e : expr) =>
(pub static $name : $T = const_repeat!([2 16 16 16 16 16] $e, $T);)
}

expensive_static!(FORCE_ALLOC: i32 = *****(&&&&&5));
4 changes: 4 additions & 0 deletions collector/benchmarks/ctfe-stress-index-check/Cargo.lock

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

4 changes: 4 additions & 0 deletions collector/benchmarks/ctfe-stress-index-check/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
name = "ctfe-stress"
version = "0.1.0"
authors = ["Ralf Jung <post@ralfj.de>"]
42 changes: 42 additions & 0 deletions collector/benchmarks/ctfe-stress-index-check/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#![feature(const_fn, const_let)]
#![allow(unused_must_use)]

// Try to make CTFE actually do a lot of computation, without producing a big result.
// 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.
([16] $e: expr, $T: ty) => {{
$e; $e; $e; $e;
$e; $e; $e; $e;
$e; $e; $e; $e;
$e; $e; $e; $e
}};
([1] $e: expr, $T: ty) => {{
$e
}};
// 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()
}};
// 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()
}};
// Recursive case: Take a 2
([2 $($n: tt)*] $e: expr, $T: ty) => {{
const fn e() -> $T { const_repeat!([$($n)*] $e, $T) }
e(); e()
}};
}
macro_rules! expensive_static {
($name: ident : $T: ty = $e : expr) =>
(pub static $name : $T = const_repeat!([2 16 16 16 16 16] $e, $T);)
}

expensive_static!(CHECKED_INDEX: u8 = b"foomp"[3]);
4 changes: 4 additions & 0 deletions collector/benchmarks/ctfe-stress-ops/Cargo.lock

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

4 changes: 4 additions & 0 deletions collector/benchmarks/ctfe-stress-ops/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
name = "ctfe-stress"
version = "0.1.0"
authors = ["Ralf Jung <post@ralfj.de>"]
42 changes: 42 additions & 0 deletions collector/benchmarks/ctfe-stress-ops/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#![feature(const_fn, const_let)]
#![allow(unused_must_use)]

// Try to make CTFE actually do a lot of computation, without producing a big result.
// 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.
([16] $e: expr, $T: ty) => {{
$e; $e; $e; $e;
$e; $e; $e; $e;
$e; $e; $e; $e;
$e; $e; $e; $e
}};
([1] $e: expr, $T: ty) => {{
$e
}};
// 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()
}};
// 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()
}};
// Recursive case: Take a 2
([2 $($n: tt)*] $e: expr, $T: ty) => {{
const fn e() -> $T { const_repeat!([$($n)*] $e, $T) }
e(); e()
}};
}
macro_rules! expensive_static {
($name: ident : $T: ty = $e : expr) =>
(pub static $name : $T = const_repeat!([16 16 16 16 16] $e, $T);)
}

expensive_static!(OPS: i32 = ((((10 >> 1) + 3) * 7) / 2 - 12) << 4);
4 changes: 4 additions & 0 deletions collector/benchmarks/ctfe-stress-reloc/Cargo.lock

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

4 changes: 4 additions & 0 deletions collector/benchmarks/ctfe-stress-reloc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
name = "ctfe-stress"
version = "0.1.0"
authors = ["Ralf Jung <post@ralfj.de>"]
42 changes: 42 additions & 0 deletions collector/benchmarks/ctfe-stress-reloc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#![feature(const_fn, const_let)]
#![allow(unused_must_use)]

// Try to make CTFE actually do a lot of computation, without producing a big result.
// 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.
([16] $e: expr, $T: ty) => {{
$e; $e; $e; $e;
$e; $e; $e; $e;
$e; $e; $e; $e;
$e; $e; $e; $e
}};
([1] $e: expr, $T: ty) => {{
$e
}};
// 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()
}};
// 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()
}};
// Recursive case: Take a 2
([2 $($n: tt)*] $e: expr, $T: ty) => {{
const fn e() -> $T { const_repeat!([$($n)*] $e, $T) }
e(); e()
}};
}
macro_rules! expensive_static {
($name: ident : $T: ty = $e : expr) =>
(pub static $name : $T = const_repeat!([2 16 16 16 16 16 16] $e, $T);)
}

expensive_static!(RELOCATIONS : &'static str = "hello");
4 changes: 4 additions & 0 deletions collector/benchmarks/ctfe-stress-unsize-slice/Cargo.lock

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

4 changes: 4 additions & 0 deletions collector/benchmarks/ctfe-stress-unsize-slice/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
name = "ctfe-stress"
version = "0.1.0"
authors = ["Ralf Jung <post@ralfj.de>"]
48 changes: 48 additions & 0 deletions collector/benchmarks/ctfe-stress-unsize-slice/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#![feature(const_fn, const_let)]
#![allow(unused_must_use)]

// Try to make CTFE actually do a lot of computation, without producing a big result.
// 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.
([16] $e: expr, $T: ty) => {{
$e; $e; $e; $e;
$e; $e; $e; $e;
$e; $e; $e; $e;
$e; $e; $e; $e
}};
([1] $e: expr, $T: ty) => {{
$e
}};
// 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()
}};
// 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()
}};
// 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()
}};
// Recursive case: Take a 2
([2 $($n: tt)*] $e: expr, $T: ty) => {{
const fn e() -> $T { const_repeat!([$($n)*] $e, $T) }
e(); e()
}};
}
macro_rules! expensive_static {
($name: ident : $T: ty = $e : expr) =>
(pub static $name : $T = const_repeat!([16 16 16 16 16 16] $e, $T);)
}

expensive_static!(UNSIZING: &'static [u8] = b"foo");