Why every developer should benchmark their code?
Imagine the following scenario: You spent weeks to rewrite the performance critical parts of your application in order to speed it up. When the product owner asks you how much faster the new implementation is you have to admit that you don’t know.
- You could spend a lot of time to write unit tests and write a lot of code without an obvious benefit.
- How can you know whether your code is faster?
- The answer is to write a benchmark that compares the performance of your new approach with the old one.
- If you write the benchmark as a part of the development process it will give you a way to know whether you’re on a good path, without forcing you to write messy and long unit tests.
Benchmarking code means avoiding time spent on the implementation of code that would be slow.