Wrapping Up
Benchmarking is a powerful technique that measures code execution speed in a fine-grained way, allowing you to know the true, actual-time difference between competing algorithms. This is especially useful when you want to compare two algorithms that fall within the same category of Big O. However, benchmarking can even reveal surprises about algorithms that aren’t in the same category. As you discovered in this chapter, in some cases, the O(N2) Insertion Sort algorithm can be faster than O(N log N) Mergesort!
On the other hand, you also learned that benchmarking is only useful when used correctly. There are numerous gotchas that can derail your experiments without you even realizing it. Therefore, it’s worthwhile to periodically look ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access