cycleburn - How to switch off gcc Optimization for a C Source Code Region
August 3, 2025
cycleburn
#
gcc allows to save the current optimization settings to a stack during compilation (#pragma GCC push_options),
to change them to a desired value (#pragma GCC optimize ("O0")). #pragma GCC pop_options restores the
previously pushed settings. The only thing to consider is that these changes need to be around a function (trying
to change the optimization settings for a few lines within a function is not supported).
Here’s the RPCL implementation of cycleburn:
|
|
This is how cycleburn is registered within RPCL:
RPCLRegister(rpcl, "cycleburn", "burn cycles ( iterations - )", RPCLInternalCycleburn);
Burning Cycles #
Testing this within an RPCL shell may look like this:
ok timer-start 10000000 cycleburn timer-show
35054 microseconds elapsed
ok ▂