Skip to content

CTFE stress benchmarks #282

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 31, 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
42 changes: 0 additions & 42 deletions collector/benchmarks/ctfe-stress-cast/src/lib.rs

This file was deleted.

4 changes: 0 additions & 4 deletions collector/benchmarks/ctfe-stress-const-fn/Cargo.lock

This file was deleted.

4 changes: 0 additions & 4 deletions collector/benchmarks/ctfe-stress-const-fn/Cargo.toml

This file was deleted.

44 changes: 0 additions & 44 deletions collector/benchmarks/ctfe-stress-const-fn/src/lib.rs

This file was deleted.

4 changes: 0 additions & 4 deletions collector/benchmarks/ctfe-stress-force-alloc/Cargo.lock

This file was deleted.

4 changes: 0 additions & 4 deletions collector/benchmarks/ctfe-stress-force-alloc/Cargo.toml

This file was deleted.

42 changes: 0 additions & 42 deletions collector/benchmarks/ctfe-stress-force-alloc/src/lib.rs

This file was deleted.

4 changes: 0 additions & 4 deletions collector/benchmarks/ctfe-stress-index-check/Cargo.lock

This file was deleted.

4 changes: 0 additions & 4 deletions collector/benchmarks/ctfe-stress-index-check/Cargo.toml

This file was deleted.

42 changes: 0 additions & 42 deletions collector/benchmarks/ctfe-stress-index-check/src/lib.rs

This file was deleted.

4 changes: 0 additions & 4 deletions collector/benchmarks/ctfe-stress-ops/Cargo.lock

This file was deleted.

4 changes: 0 additions & 4 deletions collector/benchmarks/ctfe-stress-ops/Cargo.toml

This file was deleted.

42 changes: 0 additions & 42 deletions collector/benchmarks/ctfe-stress-ops/src/lib.rs

This file was deleted.

4 changes: 0 additions & 4 deletions collector/benchmarks/ctfe-stress-reloc/Cargo.lock

This file was deleted.

4 changes: 0 additions & 4 deletions collector/benchmarks/ctfe-stress-reloc/Cargo.toml

This file was deleted.

42 changes: 0 additions & 42 deletions collector/benchmarks/ctfe-stress-reloc/src/lib.rs

This file was deleted.

4 changes: 0 additions & 4 deletions collector/benchmarks/ctfe-stress-unsize-slice/Cargo.lock

This file was deleted.

4 changes: 0 additions & 4 deletions collector/benchmarks/ctfe-stress-unsize-slice/Cargo.toml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![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.
Expand Down Expand Up @@ -41,8 +40,23 @@ macro_rules! const_repeat {
}};
}
macro_rules! expensive_static {
($name: ident : $T: ty = $e : expr) =>
(pub static $name : $T = const_repeat!([16 16 16 16 16 16] $e, $T);)
($name: ident : $T: ty = $e : expr; $count: tt) =>
(pub static $name : $T = const_repeat!($count $e, $T);)
}

expensive_static!(UNSIZING: &'static [u8] = b"foo");
pub trait Trait: Sync {}
impl Trait for u32 {}

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

// The numbers in the brackets are iteration counts. E.g., [4 16 16] means
// 4 * 16 * 16 = 2^(2+4+4) = 2^10 iterations.
expensive_static!(CAST: usize = 42i32 as u8 as u64 as i8 as isize as usize; [8 16 16 16 16]);
expensive_static!(CONST_FN: i32 = inc(42); [8 16 16 16 16]);
expensive_static!(FIELDS: &'static i32 = &("bar", 42, "foo", 3.14).1; [8 16 16 16 16]);
expensive_static!(FORCE_ALLOC: i32 = *****(&&&&&5); [8 16 16 16 16]);
expensive_static!(CHECKED_INDEX: u8 = b"foomp"[3]; [8 16 16 16 16]);
expensive_static!(OPS: i32 = ((((10 >> 1) + 3) * 7) / 2 - 12) << 4; [4 16 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]);