-
Notifications
You must be signed in to change notification settings - Fork 10
dev PerformanceCoding
oguyon edited this page Apr 10, 2021
·
1 revision
A few guidelines to provide information to the compiler (and the programmer).
Use const
const float pi = 3.14;
printf("pi = %f\n", pi);
Use restrict type qualifying for non-aliased pointers
errno_t examplefunction(
const char *__restrict__ stringinput
)
{
printf("string : %s\n", stringinput);
return RETURN_SUCCESS;
}
For details, see GCC Common Function Attributes
void __attribute__ ((pure)) myfunction()
{
// function that has no observable effects on the state of the program other than to return a value
}
void __attribute__ ((hot)) myfunction()
{
// some performance-critical code
}
void __attribute__ ((cold)) myfunction()
{
// some non-performance-critical code
}
Modular Image processing Library toolKit (milk) - https://github.com/milk-org/milk