Skip to content

Commit cd44ae1

Browse files
Merge pull request #282 from RalfJung/ctfe-stress
CTFE stress benchmarks
2 parents 8377535 + c175d39 commit cd44ae1

File tree

21 files changed

+18
-306
lines changed

21 files changed

+18
-306
lines changed

collector/benchmarks/ctfe-stress-cast/src/lib.rs

Lines changed: 0 additions & 42 deletions
This file was deleted.

collector/benchmarks/ctfe-stress-const-fn/Cargo.lock

Lines changed: 0 additions & 4 deletions
This file was deleted.

collector/benchmarks/ctfe-stress-const-fn/Cargo.toml

Lines changed: 0 additions & 4 deletions
This file was deleted.

collector/benchmarks/ctfe-stress-const-fn/src/lib.rs

Lines changed: 0 additions & 44 deletions
This file was deleted.

collector/benchmarks/ctfe-stress-force-alloc/Cargo.lock

Lines changed: 0 additions & 4 deletions
This file was deleted.

collector/benchmarks/ctfe-stress-force-alloc/Cargo.toml

Lines changed: 0 additions & 4 deletions
This file was deleted.

collector/benchmarks/ctfe-stress-force-alloc/src/lib.rs

Lines changed: 0 additions & 42 deletions
This file was deleted.

collector/benchmarks/ctfe-stress-index-check/Cargo.lock

Lines changed: 0 additions & 4 deletions
This file was deleted.

collector/benchmarks/ctfe-stress-index-check/Cargo.toml

Lines changed: 0 additions & 4 deletions
This file was deleted.

collector/benchmarks/ctfe-stress-index-check/src/lib.rs

Lines changed: 0 additions & 42 deletions
This file was deleted.

collector/benchmarks/ctfe-stress-ops/Cargo.lock

Lines changed: 0 additions & 4 deletions
This file was deleted.

collector/benchmarks/ctfe-stress-ops/Cargo.toml

Lines changed: 0 additions & 4 deletions
This file was deleted.

collector/benchmarks/ctfe-stress-ops/src/lib.rs

Lines changed: 0 additions & 42 deletions
This file was deleted.

collector/benchmarks/ctfe-stress-reloc/Cargo.lock

Lines changed: 0 additions & 4 deletions
This file was deleted.

collector/benchmarks/ctfe-stress-reloc/Cargo.toml

Lines changed: 0 additions & 4 deletions
This file was deleted.

collector/benchmarks/ctfe-stress-reloc/src/lib.rs

Lines changed: 0 additions & 42 deletions
This file was deleted.

collector/benchmarks/ctfe-stress-unsize-slice/Cargo.lock

Lines changed: 0 additions & 4 deletions
This file was deleted.

collector/benchmarks/ctfe-stress-unsize-slice/Cargo.toml

Lines changed: 0 additions & 4 deletions
This file was deleted.

collector/benchmarks/ctfe-stress-unsize-slice/src/lib.rs renamed to collector/benchmarks/ctfe-stress/src/lib.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![feature(const_fn, const_let)]
2-
#![allow(unused_must_use)]
32

43
// Try to make CTFE actually do a lot of computation, without producing a big result.
54
// And without support for loops.
@@ -41,8 +40,23 @@ macro_rules! const_repeat {
4140
}};
4241
}
4342
macro_rules! expensive_static {
44-
($name: ident : $T: ty = $e : expr) =>
45-
(pub static $name : $T = const_repeat!([16 16 16 16 16 16] $e, $T);)
43+
($name: ident : $T: ty = $e : expr; $count: tt) =>
44+
(pub static $name : $T = const_repeat!($count $e, $T);)
4645
}
4746

48-
expensive_static!(UNSIZING: &'static [u8] = b"foo");
47+
pub trait Trait: Sync {}
48+
impl Trait for u32 {}
49+
50+
const fn inc(i: i32) -> i32 { i + 1 }
51+
52+
// The numbers in the brackets are iteration counts. E.g., [4 16 16] means
53+
// 4 * 16 * 16 = 2^(2+4+4) = 2^10 iterations.
54+
expensive_static!(CAST: usize = 42i32 as u8 as u64 as i8 as isize as usize; [8 16 16 16 16]);
55+
expensive_static!(CONST_FN: i32 = inc(42); [8 16 16 16 16]);
56+
expensive_static!(FIELDS: &'static i32 = &("bar", 42, "foo", 3.14).1; [8 16 16 16 16]);
57+
expensive_static!(FORCE_ALLOC: i32 = *****(&&&&&5); [8 16 16 16 16]);
58+
expensive_static!(CHECKED_INDEX: u8 = b"foomp"[3]; [8 16 16 16 16]);
59+
expensive_static!(OPS: i32 = ((((10 >> 1) + 3) * 7) / 2 - 12) << 4; [4 16 16 16 16]);
60+
expensive_static!(RELOCATIONS : &'static str = "hello"; [8 16 16 16 16]);
61+
expensive_static!(UNSIZE_SLICE: &'static [u8] = b"foo"; [4 16 16 16 16 16]);
62+
expensive_static!(UNSIZE_TRAIT: &'static Trait = &42u32; [4 16 16 16 16 16]);

0 commit comments

Comments
 (0)