Benchmarking runtime performance in the terminal

Benchmarking runtime is the process of timing how long it takes the code to run. This skill is invaluable since it helps compare performance. By externally measuring the runtime as opposed to instrumenting it within the code, we can easily proceed without understanding the inner working of the code. If we're on a Unix-like system such as Linux or OS X, we can use the time command, and on Windows systems, we can use Measure-Command with PowerShell.

Getting ready

Make sure our machine is either Unix-like (such as Linux or OS X) or Windows. Otherwise, we must search online for a way to time execution.

How to do it…

  1. On Unix-like systems, there is a built-in time command. When running any piece of code from ...

Get Haskell Data Analysis Cookbook 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.