Unit testing your code’s performance, part 1: Big-O scaling
When you implement an algorithm, you also implement tests to make sure the outputs are correct.
This can help you:
- Ensure your code is correct.
- Catch problems if and when you change it in the future.
If you’re trying to make sure your software is fast, or at least doesn’t get slower, automated tests for performance would also be useful.
But where should you start?
My suggestion: start by testing big-O scaling.
It’s a critical aspect of your software’s speed, and it doesn’t require a complex benchmarking setup.
In this article I’ll cover:
- A reminder of what big-O scaling means for algorithms.
- Why this is such a critical performance property.
- Identifying your algorithm’s scalability, including empirically with the
bigOlibrary. - Using the
bigOlibrary