Benchmarking using the criterion library
Profiling aside, benchmarking the time a calculation takes to perform is a direct indicator of real-world performance. Benchmarking Haskell applications is pretty much dominated by the criterion library. There is a system called nofib
, which is used to benchmark GHC itself, but for applications criterion is superior. Criterion even produces interactive web pages describing the results of benchmarks, which is a nice feature.
This text is written for criterion-1.1.1.0. Obviously, the criterion
package needs to be installed:
cabal install criterion # or: stack install criterion
A criterion benchmark suite is created as a normal Haskell program. An example is this:
–– file: benchmark.hs import Criterion.Main ...
Get Haskell High Performance Programming 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.