opt_level::OPT_LEVEL
Get the value of rustc's -Copt-level= flag at runtime.
Useful for sizing tests to run fewer iterations in slow build modes.
According to https://doc.rust-lang.org/cargo/reference/profiles.html#opt-level the possible values are:
- 0: no optimizations
- 1: basic optimizations
- 2: some optimizations
- 3: all optimizations
- s: optimize for binary size
- z: optimize for binary size, but also turn off loop vectorization
Example
use SmallRng;
use ;
const N: usize = if cfg! else if let b"0" = OPT_LEVEL.as_bytes else ;