fn black_box
Returns x unchanged while hiding it from the optimizer, so that a benchmark's work is not optimized away (D-7053).
Example:
use std.test { black_box }
test bench "sum of a range" {
let n = black_box(1000)
var s = 0
for i in 0..n { s += i }
black_box(s)
}@intrinsic("test.blackBox") pub(api) fn black_box<T>(x: T) -> TComplexity. O(1).
Since. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
x | T |
Returns
T
Effects
none declared (pure unless the body says otherwise)
Defined in: std/test/test.oxl:428