streamly/benchmark
Harendra Kumar dbc1956141 Review of #138 (Prelude functions) and other changes
APIs
----

Removed:
  merge
  lazy left scans: scanl, scanlM, scanl1, scanl1M

Renamed:
  generate and generateM renamed to fromIndices and fromIndicesM

Added:
  replicate
  mergeByM, mergeAsyncBy, mergeAsyncByM
  `intFrom`, `intFromTo`, `intFromThen`, `intFromThenTo`,
  `intFromStep`, `fracFrom`, `fracFromThen`, `fracFromThenTo`,
  `numFromStep`

Added StreamD version of replicateM and a rewrite rule for replicateMSerial.

Added but not exposed:
  postscanl and prescanl ops

Rewrote mergeByS in StreamK, simplified quite a bit and got some perf
improvement too.

Added @since notations to new APIs.

Fixed lines exceeding 80 columns.

Tests
-----

Added tests for the new enumeration APIs.
Improved some tests by generating values randomly using quickcheck forAll. We
can improve more tests similarly.

Removed some redundant transformOps tests.

reorganized test code in groups so as to keep similar functionality together
and added header lines so that we can find relevant code easily.

Benchmarks
----------

Added benchmarks for enumeration primitives added above. Added benchmarks for
scan and fold mixed ops. Added benchmark for concatMap. Fixed foldr and foldrM
benchmarks to use a (+) operation instead of a list operation for fair
comparision with other folds.

Kept only one benchmark each for deleteBy, insertBy, isPrefixOf and
isSubsequenceOf.

Documentation
-------------

Updated documentation, added examples for the new primitives as well as many
old ones. Especially the documentation of folds and scans was rewritten.

Reordered and re-organized the groups of APIs in the doc.

Refactoring
-----------

Some related and urelated refactoring.

Hlint
-----

Fixed some hlint hints introduced recently.

TBD
---

Some APIs need concurrent versions. I have added "XXX" notes for those.
Some more tests have to be added.
Some more benchmarks have to be added.
2018-12-09 19:39:37 +05:30
..
Adaptive.hs lint free benchmarks 2018-10-13 08:52:09 +05:30
BaseStreams.hs Add pure stream (list) instances 2018-11-16 14:39:26 +05:30
Chart.hs Add pure stream (list) instances 2018-11-16 14:39:26 +05:30
Linear.hs Review of #138 (Prelude functions) and other changes 2018-12-09 19:39:37 +05:30
LinearAsync.hs Add transformation/filtering/mixed composition benchmarks 2018-10-29 00:21:16 +05:30
LinearOps.hs Review of #138 (Prelude functions) and other changes 2018-12-09 19:39:37 +05:30
LinearRate.hs lint free benchmarks 2018-10-13 08:52:09 +05:30
NanoBenchmarks.hs Add isolated benchmarks to investigate special cases 2018-11-06 04:36:41 +05:30
Nested.hs lint free benchmarks 2018-10-13 08:52:09 +05:30
NestedOps.hs lint free benchmarks 2018-10-13 08:52:09 +05:30
README.md Add a README for benchmarks 2018-10-27 14:22:11 +05:30
StreamDOps.hs Add pure stream (list) instances 2018-11-16 14:39:26 +05:30
StreamKOps.hs Add pure stream (list) instances 2018-11-16 14:39:26 +05:30

Running Benchmarks

bench.sh script at the root of the repo is the top level driver for running benchmarks. It runs the requested benchmarks and then creates a report from the results using the bench-show package. Try bench.sh --help for available options to run it.

Quick start

Run these commands from the root of the repo.

To run the default benchmarks:

$ ./bench.sh

To run all benchmarks:

$ ./bench.sh --benchmarks all

To run linear and linear-async benchmarks:

$ ./bench.sh --benchmarks "linear linear-async"

To run only the base benchmark and only the benchmarks prefixed with StreamD in that (anything after a -- is passed to gauge):

$ ./bench.sh --benchmarks base -- StreamD

Comparing benchmarks

To compare two sets of results, first run the benchmarks at the baseline commit:

$ ./bench.sh

And then run with the --append option at the commit that you want to compare with the baseline. It will show the comparison with the baseline:

$ ./bench.sh --append

Append just adds the next set of results in the same results file. You can keep appending more results and all of them will be compared with the baseline.

You can use --compare to compare the previous commit with the head commit:

$ ./bench.sh --compare

To compare the head commit with some other base commit:

$ ./bench.sh --compare --base d918833

To compare two arbitrary commits:

$ ./bench.sh --compare --base d918833 --candidate 38aa5f2

Note that the above may not always work because the script and the benchmarks themselves might have changed across the commits. The --append method is more reliable to compare.

Available Benchmarks

The benchmark names that you can use when running bench.sh:

  • base: a benchmark that measures the raw operations of the basic streams StreamD and StreamK.

  • linear: measures the non-monadic operations of serial streams

  • linear-async: measures the non-monadic operations of concurrent streams

  • linear-rate: measures the rate limiting operations

  • nested: measures the monadic operations of all streams

  • all: runs all of the above benchmarks

Reporting without measuring

You can use the --no-measure option to report the already measured results in the benchmarks results file. A results file may collect an arbitrary number of results by running with --append multiple times. Each benchmark has its own results file, for example the linear benchmark has the results file at charts/linear/results.csv.

You can also manually edit the file to remove a set of results if you like or to append results from previously saved results or from some other results file. After editing you can run bench.sh with the --no-measure option to see the reports corresponding to the results.