The method invocation method slows down code execution in a tiny bit if they are not embedded in the C # compiler or jit compiler. However, if your code doesn't run in a loop and runs a million times or so, you should focus on creating clean, understandable, and maintainable code. When I started with programming, the runtime for individual statements was measured in milliseconds or microseconds. Today they are measured in nanoseconds. Usually time is spent mainly on I / O operations. Bad algorithms can also be blamed several times. If your design is clearly structured, it is much easier to replace the poorly executed part of the code with a better one, compared to the time-optimized code from the very beginning and, therefore, probably poorly structured.
I survived this recently. I had to create complex graphics in Visio in a C # program. It turned out that Visio automation was very slow. It took several minutes to create the graphics. Fortunately, I placed all the graphics components in a component that opened graphics commands through the neutral interface of the product. Ie: The interface did not contain specific Visio materials. It was very easy to replace the Visio component with a new SVG component that performed the same task in less than a second. In addition, absolutely no changes should have been made in my algorithms or in any other part of my program.
Because of this, my graphical component adds more method calls. In addition, it can be accessed through the interface, which further slows down the work. However, in the end, it was this interface and these additional method calls that allowed me to implement a much faster solution. Remember: minutes versus less than one second!
source share