10 Benchmarking and profiling

This chapter covers

  • Benchmarking code in Haskell
  • Exploring time and space consumption
  • Tips and tricks to optimize code

In this chapter, we’ll discuss how to check the performance of our code. As usual, we are interested in time and space usage characteristics. We’ll discuss how to compare different implementations of the same function in terms of execution time using benchmarking and choose the most suitable implementation. We’ll explore time and space consumption of our programs (we call it profiling) and use this information to find drawbacks in the implementation, such as space leaks. Finally, we’ll see how to use benchmarking and profiling to make our programs run faster.

Remember, we’ve already implemented ...

Get Haskell in Depth now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.