Clean Code & Performance

Info

What is the impact of Clean Code on Software Performance?

Design Patterns

Design patterns impact on energy efficiency

๐Ÿ”— References

"Clean" Code, Horrible Performance - by Casey Muratori

When we look at the results, we see something rather remarkable: just that one change โ€” writing the code the old fashioned way rather than the โ€œcleanโ€ code way โ€” gave us an immediate 1.5x performance increase. Thatโ€™s a free 1.5x for not doing anything other than removing the extraneous stuff required to use C++ polymorphism.

The ideas underlying the โ€œcleanโ€ code methodology are almost all horrible for performance, and you shouldnโ€™t do them.

Is Elegant JavaScript Always Performant? Concise vs. Fast Code Explained | by Yuri Bett | Nov, 2023 | JavaScript in Plain English

While the forEach method is less verbose and looks cleaner, it's generally slower than the traditional for loop due to the extra function call overhead for each iteration.

Set.has is more performant than Array.includes

if we need to search a dataset multiple times, a better option would be to create an index

you can often make a program faster by using more memory (space)

----------------------
Time taken for fibonacciRecursive with input 35: 89.2701244354248 milliseconds
----------------------
Time taken for fibonacciMemoization with input 35: 0.028415679931640625 milliseconds
----------------------
Time taken for fibonacciIterative with input 35: 0.01462554931640625 milliseconds
----------------------
Time taken for fibonacciMemoization with input 1000: 0.17408275604248047 milliseconds
----------------------
Time taken for fibonacciIterative with input 1000: 0.13091564178466797 milliseconds