Benchmarking
Use benchmarking tools to compare different implementations to the same problem. Proper benchmarking requires care: we need to guarantee a measurement won’t affect subsequent ones. For example, each measurement should run on a new process to make sure data generated in the first measurement won’t affect the second one by triggering the garbage collector. We also need to make sure we warm up the code before each measurement, to make sure the VM won’t kick in dynamic code loading for some cases but not others. The details are tricky so most folks use a benchmarking tool instead of rolling their own solutions.
Imagine that your application needs to find the longest word from a file. Each word is on a separate line. Initially everything ...
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