At first it influences performance. But it may not influence by a number of factors.
A call to a function, in addition to the instructions for deviation and return of the flow of the program to another address, there may be a copy of the parameters, either from memory to memory or through registers. So it's cost, of course.
If the function is simple and depending on the options used to compile the program the function will be optimized through the inline expansion . That is, if advantageous, the compiler removes the call from the function and places its code where the call was made. Note that the compiler knows that there are cases where using this technique will produce the opposite result.
This does the same thing the macro would do but much better. At first the compilers were not able to do this and the macros had this advantage, despite the disadvantages that this feature has. Today there are no major reasons for using the macro, only very specific situations require its use in C-code and still less in C ++ code that has even better features.
It is possible to make macros more complex than simple arithmetic operations but is not recommended for use today. But as I said before macros do not understand the context where they are running, this can cause problems if care is not taken in their creation and / or use.
Example:
#define exemplo() \
do { \
faz alguma coisa aqui \
} while (0)
Today you have no more reason to do this. Today even in C, most of the time the programmer should be concerned with the readability of the code and not with the performance. The compiler will make the code be as fast as possible in the vast majority of situations that the code is well written. You do not have to be looking for the best ways to write thinking primarily about performance. When the performance is not enough, then one must think about what to do to improve that stretch. rarely will the macro be the solution for this case.
In almost 100% of cases the compiler will know if a function must be "linearized" for better performance. If he does not do this is because he understands that there will be no gain and he hits more than programmers usually do.
It seems to me that some compilers may force inline , through a specific flag even when it is not recommended. Almost always when the programmer wants to be smarter than the compiler, it fails.
Your example is sure to be "linearized," unless the compiler is told not to do it. But a small change that will still leave the short function will probably prevent this from happening:
void minhafuncao(){
for (int i = 0; i < 100; i++) printf("Funcao");
}
Probably the time spent inside the function is large enough for the compiler to understand that there will be no gain. But other factors can be taken into account for evaluation.
I will not go into details of what is done or not because I do not know deeply and depends on implementation, that is, it can change in each version or brand of the compiler.
A test can be applied to see if there is a difference or not:
#include <stdio.h>
#include <time.h>
int minhafuncao(){
int x = 0;
x++;
return x;
}
int main () {
clock_t begin, end;
double time_spent;
int x;
begin = clock();
for (int i = 0; i < 300000000; i++);
end = clock();
time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
printf ("Tempo gasto %.2lf segundos.\n", time_spent);
begin = clock();
for (int i = 0; i < 300000000; i++) minhafuncao();
end = clock();
time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
printf ("Tempo gasto %.2lf segundos.\n", time_spent);
begin = clock();
for (int i = 0; i < 300000000; i++) x++;
end = clock();
time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
printf ("Tempo gasto %.2lf segundos.\n", time_spent);
x++;
return 0;
}
Ideone is not the best environment to take the test , but you can get an idea. I recommend doing your test. The result may be different under different conditions.
Another test without returning a value. Notice how it changes.