Basic benchmarking


Aug 29, 2020
haskell

My first blog post using slick and in a long while...

Bench is a cool tool written in Haskell using the criterion for benchmarking commands in the shell. (edit: In 2022 you might also consider to use the simpler Haskell tasty-bench library instead.)

A while back hlint got me interested in different ways to do reverse (descending) sort in Haskell, from a 2016 article by Roman Cheplyaka.

As I am starting to work on adding typed-process to the next major version of simple-cmd and I had noticed a slowdown while experimenting with typed-process in rpmbuild-order, I thought I would try to measure the overhead of using typed-process compared to just process for simple command output.

So this is not really a very fair comparison since typed-process uses heavier machinery like stm and async to correctly buffer and pipe input and output, but for short lived commands there is measureable overhead. I need to experiment more (maybe I should try ghc profiling too) but I may end up using a hybrid approach of process for simple commands and typed-process for more sophisticated I/O stream handling: for example to fix bugs in the current piping commands in simple-cmd and also add a tee function, etc. I wonder if there could be any lower hanging fruit that could improve the performance of typed-process? but so far that looks hard to see.

ps (added 2022) For an example of using tasty-bench, see my tiny hs-string-bench project.