How to use std.mem.doNotOptimizeAway()
?
-
It seems like projects apply the function to an output
value of the benchmark, that output value is an
accumulator of the intermediaries of what is being
benchmarked, for example it could be a sum of calculated valuesexamples:
zig/lib/std/hash/benchmark.zig at master · ziglang/zig · GitHub
GitHub - karlseguin/benchmark.zig: Simple Benchmarking for Zig -
how does it work?
it creates an asm block that looks opaque for the compiler
so that it has to assume that it can’t optimize the result away?
This is just a bit of what I had already, if you have corrections better explanaitions those are of course welcome.