The cost of calling function is small or large depending on how you look. In generates the cost is to save some registers in memory (most likely it will be in the L1 cache which is very fast, and then recover the original state of the registers.
In addition there may be data copies because of the parameter pass. If this would not happen if it were not a function it depends.
Under certain circumstances the compiler can linearize the function , that is, instead of calling it (< in> call ) it copies the function code to the place it was calling. You will achieve readability and performance.
If the compiler does not do this, it is because it can not (okay, there are situations that the human knows that it can and the compiler does not) or does not compensate for the inline function.
In the linked question above I say this. If the function is not lowercase and run for a very short time does not compensate. It also does not pay to optimize what will be called a few times, but this is not always the case for the compiler.
The programmer may know until something is called many times but actually in a lot of place that there is natural waiting, so performance does not matter at all.
It is true that on devices with reduced resources it may be useful to do a little more optimization. Optimization can be much worse in these cases because gaining performance loses memory and low memory greatly affects performance. And one of the scarce resources is battery power. Faster code is usually more economical code.
In the past, when computers were less powerful, this was far more important.
The performance is negligible in most cases and where it is not the compiler helps you. Of course there may be if the performance is bad. But most likely the algorithm is bad and not the call of the function that is in the way.
There are cases where the linearization of the function can cause extra costs and what seemed a certain performance gain, gives the opposite. And as the difference is very small, the programmer "smart" who did what he thought would give a better performance ends up not even realizing that he did the worst, although this worse also will not disturb anything.
I will never say forever prefer to reproduce the code than to call it, but rarely does this need to be done, and only do so after verifying that the performance is not as expected (you have to measure it). The cost of optimizing may not outweigh the gain. Because maintenance becomes more difficult. You break the DRY .
Of course between the readability with less performance and the legible with more performance I prefer the one with more performance. But copying the code to avoid the call will hardly be more readable than calling it.
If a person uses PHP primarily, or Java or C #, they do not want maximum performance. These languages can be fast, they can benefit from this optimization, but it is not so common to need this. When you need a lot of performance in general C or C ++ is preferred. In this language it makes more sense to eliminate function calls, but depends on the application, it depends on the point of the application.
The question talks about memory consumption as well. The function will use more memory to save the registers and may also spend a little more because of the parameter copy, but not always. If the code was right this does not matter, because the memory used is stack which is already allocated using it or not.
You need a profiler to check how the code is running and to indicate the costs. Valgrind is best known for Linux and Windows should probably be using Visual Studio which has a profiler .
There are other ways, but this is the most accurate and correct.