folly::makeUnpredictable

Hide a value from the optimizer so it cannot shape the following code.

Synopsis

Declared in <folly/BenchmarkUtil.h>

template<typename T>
void
makeUnpredictable(T& datum);

Description

Call makeUnpredictable(var) when you don't want the optimizer to use its knowledge of var to shape the following code. This is useful when constant propagation or power reduction is possible during your benchmark but not in real use cases.

Parameters

NameDescription
datumThe value to make opaque to the optimizer.