Book Image

Haskell Data Analysis Cookbook

By : Nishant Shukla
Book Image

Haskell Data Analysis Cookbook

By: Nishant Shukla

Overview of this book

Table of Contents (19 chapters)
Haskell Data Analysis Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 the terminal, we can prefix it with time as follows:

    $ time runhaskell Main.hs
    real 0m0.663s
    user 0m0.612s
    sys 0m0.057s
    

    The argument to this command is run, and the system resource usage is immediately summarized. The actual accuracy of the results...