Skip to main content

Mojo function

keep

keep[Type: AnyType, origin: ImmutOrigin, //](ref [origin] val: Type)

Provides a hint to the compiler to not optimize the variable use away.

This is useful in benchmarking to avoid the compiler not deleting the code to be benchmarked because the variable is not used in a side-effecting manner.

Parameters:

  • โ€‹Type (AnyType): The type of the input.
  • โ€‹origin (ImmutOrigin): The origin of the input.

Args:

  • โ€‹val (Type): The value to not optimize away.

Was this page helpful?