I am surprised that we are not asking what performance problems you have!
In my experience, performance problems are usually related to specific conditions and situations. Design patterns, on the other hand, are solutions to more general and abstract problems. It would seem a little inconvenient to approach both in the same text: and what, perhaps, in many “unstructured” solutions, if the author compares the performance of the design pattern? When the performance problem is common, there are probably already templates to solve them: weight is a good example.
The fines imposed using the design pattern have a finite, very small set: introducing virtual calls, adding delay due to delegation, additional memory consumption due to the distribution of objects, etc. If after profiling you notice that this is the cause of your problems, there are known ways to minimize them.
Knowing patterns can be useful for solving performance issues. First, someone already mentioned that patterns break the problem down into smaller bits: this can make it easier to identify the source of the problem and highlight the ugly but perfect code. They also provide a framework for the reasoning and expectations of developers. If you must introduce a deviation for performance reasons, it will be obvious: "Except here, when we give up X and do Y to improve performance, this is a chain of responsibility." These are the rules that need to be broken if necessary.
(Alas, there is one very good template for getting good performance: measurement, accurate, correction.)
andref
source share