criterion 1.0

Almost five years after I initially released criterion, I'm delighted to announce a major release with a large number of appealing new features.

As always, you can install the latest goodness using cabal install criterion, or fetch the source from github.

Please let me know if you find criterion useful!

New documentation

I built both a home page and a thorough tutorial for criterion. I've also extended the inline documentation and added a number of new examples.

All of the documentation lives in the github repo, so if you'd like to see something improved, please send a bug report or pull request.

New execution engine

Criterion's model of execution has evolved, becoming vastly more reliable and accurate. It can now measure events that take just a few hundred picoseconds.

benchmarking return ()
time                 512.9 ps   (512.8 ps .. 513.1 ps)

While almost all of the core types have changed, criterion should remain API-compatible with the vast majority of your benchmarking code.

New metrics

In addition to wall-clock time, criterion can now measure and regress on the following metrics:

  • CPU time
  • CPU cycles
  • bytes allocated
  • number of garbage collections
  • number of bytes copied during GC
  • wall-clock time spent in mutator threads
  • CPU time spent running mutator threads
  • wall-clock time spent doing GC
  • CPU time spent doing GC

Linear regression

Criterion now supports linear regression of a number of metrics.

Here's a regression conducted using --regress cycles:iters:

cycles:              1.000 R²   (1.000 R² .. 1.000 R²)
  iters              47.718     (47.657 .. 47.805)

The first line of the output is the R² goodness-of-fit measure for this regression, and the second is the number of CPU cycles (measured using the rdtsc instruction) to execute the operation in question (integer division).

This next regression uses --regress allocated:iters to measure the number of bytes allocated while constructing an IntMap of 40,000 values.

allocated:           1.000 R²   (1.000 R² .. 1.000 R²)
  iters              4.382e7    (4.379e7 .. 4.384e7)

(That's a little under 42 megabytes.)

New outputs

While its support for active HTML has improved, criterion can also now output JSON and JUnit XML files.

New internals

Criterion has received its first spring cleaning, and is much easier to understand as a result.


I was inspired into some of this work by the efforts of the authors of the OCaml Core_bench package.

Posted in haskell, open source
9 comments on “criterion 1.0
  1. Thanks for the sharing. The Criterion is very useful to me

  2. inz executive condo brickland says:

    Great posting. I am searching for this

  3. cck ec says:

    Thankful for this page. This is my year end topic for school project

  4. It is a parsing combinator library that is “aimed particularly at dealing efficiently with network protocols and complicated text/binary

  5. Anam says:

    Thanks for the sharing.

  6. Julia says:

    Thankful for this page. This is my year end topic for school project

  7. Angel17 says:

    I am thankful to this site for posting such a wonderful and informative blog. Keep posting. accessories and more

  8. Kelly says:

    So if you’d like to see something improved, please send a bug report or pull request.

    Kelly | ceiling patterns

  9. Jonel says:

    handyman near me is looking forward to exploring the latest goodness and continued excellence in benchmarking with Criterion! 👏🚀

Leave a Reply

Your email address will not be published. Required fields are marked *