Marks program source code that you expect will be either very frequently or very infrequently executed.
When optimization is enabled, the pragma is used as a hint to the optimizer.
Use this pragma in conjunction with an optimization option; if optimization is not enabled, the pragma has no effect.
The pragma must be placed within block scope, and acts on the closest point of branching.
int *array = (int *) malloc(10000);
if (array == NULL) {
/* Block A */
#pragma execution_frequency(very_low)
error();
}
if (Foo > 0) {
#pragma execution_frequency(very_low)
/* Block B */
doSomething();
} else {
/* Block C */
doAnotherThing();
}
while (counter > 0) {
#pragma execution_frequency(very_high)
doSomething();
} /* This loop is very likely to be executed. */
switch (a) {
case 1:
doOneThing();
break;
case 2:
#pragma execution_frequency(very_high)
doTwoThings();
break;
default:
doNothing();
} /* The second case is frequently chosen. */
int a;
#pragma execution_frequency(very_low)
int b;
int foo(boolean boo) {
#pragma execution_frequency(very_low)
char c;
if (boo) {
/* Block A */
doSomething();
{
/* Block C */
doSomethingAgain();
#pragma execution_frequency(very_low)
doAnotherThing();
}
} else {
/* Block B */
doNothing();
}
return 0;
}
#pragma execution_frequency(very_low)