Commit Graph

100 Commits

Author SHA1 Message Date
Harendra Kumar
df633139c2 Move benchmark code for parsers to its own module 2020-04-09 04:06:57 +05:30
Harendra Kumar
2723c15d36 Implement stream parsing
This is the initial version of stream parsing. It implements a "Parse"
type, some parsers based on that type, applicative composition, operations to
run parsers (parse) and to run parsers over chunks of a stream (parseChunks).

Parsers are just an extension of Folds in Streamly.Data.Fold. Parsers just add
backtracking and failure capabilities to folds.

Operations like splitOn to split a stream on a predicate can now be expressed
using a parser applied repeatedly on a stream. For example, line splitting can
be done using parsers. Parsers are as fast as fastest custom code for
line splitting.
2020-04-09 04:06:57 +05:30
adithyaov
633e88f8c5 Move unfold benchmarks out of prelude. Make a seperate exec. 2020-04-08 19:38:33 +05:30
adithyaov
24e481c00a Mv multiple modules from b/ to b/Streamly/Benchmark/Prelude
benchmark/Adaptive.hs -> benchmark/Streamly/Benchmark/Prelude/Adaptive.hs
benchmark/Concurrent.hs -> benchmark/Streamly/Benchmark/Prelude/Concurrent.hs
benchmark/LinearAsync.hs -> benchmark/Streamly/Benchmark/Prelude/LinearAsync.hs
benchmark/LinearRate.hs -> benchmark/Streamly/Benchmark/Prelude/LinearRate.hs
benchmark/NestedConcurrent.hs -> benchmark/Streamly/Benchmark/Prelude/NestedConcurrent.hs
benchmark/Parallel.hs -> benchmark/Streamly/Benchmark/Prelude/Parallel.hs
2020-04-08 19:38:33 +05:30
adithyaov
18949ef414 Move b/NestedOps.hs and b/NestedUnfoldOps.hs to b/Streamly/Benchmark 2020-04-08 19:38:33 +05:30
adithyaov
82e19d6cea Move benchmark/Array* to benchmark/Streamly/Benchmark/Memory/* 2020-04-08 19:38:33 +05:30
adithyaov
9797d7615d Make a sandalone fold executable. 2020-03-29 18:40:51 +05:30
adithyaov
18c903f5c4 Seperate folds from Prelude in benchmarks. 2020-03-18 11:31:01 +05:30
Harendra Kumar
5e1736c4f1 Comment out foldlS benchmark
It takes too much time, holding up benchmarking for too long.
2020-02-28 21:20:37 +05:30
Harendra Kumar
e76546fbb1 format some parts of the benchmarking code 2020-02-28 19:58:06 +05:30
adithyaov
b62c02f44a Merge O_n_Stack.hs into Prelude.hs
* Benchmark/Prelude/Serial/O_n_Stack ->
  lib/Streamly/Benchmark/Prelude.hs
* Modify O_n_Stack.hs accordingly
2020-02-28 19:58:06 +05:30
adithyaov
69a81af68d Merge O_n_Heap.hs into Prelude.hs
* Benchmark/Prelude/Serial/O_n_Heap ->
  lib/Streamly/Benchmark/Prelude.hs
* Modify O_n_Heap.hs accordingly
2020-02-28 19:58:06 +05:30
adithyaov
8544b1f1e7 Merge O_n_Space.hs into Prelude.hs
* Benchmark/Prelude/Serial/O_n_Space ->
  lib/Streamly/Benchmark/Prelude.hs
* Modify O_n_Space.hs accordingly
2020-02-28 19:58:06 +05:30
adithyaov
4d59cb3afe Merge lib/B/Groups.hs into lib/B/Prelude.hs
* Remove lib/B/Group.hs
* The idea: Have all the groups in Prelude and
  export only the groups, that way, all the functions
  aren't compiled multiple times (without and with
  inlining).
2020-02-28 19:58:06 +05:30
adithyaov
2dacf99488 Move and split benchmarks from O_1_Space.hs to Groups.hs
* Streamly/Benchmark/Prelude/O_1_Space.hs ->
lib/Streamly/Benchmark/Groups.hs

* Modify O_1_Space.hs accordingly
2020-02-28 19:58:06 +05:30
Harendra Kumar
eccf24a4b1 Add singletonM, update some docs 2020-02-26 13:44:25 +05:30
Harendra Kumar
166bd93267 refactor "base" stream benchmarks
push the benchmark definitions from the top level "BaseStreams.hs" file to the
individual stream modules to improve modularity.
2020-02-21 16:32:46 +05:30
Harendra Kumar
ae30f2fc9e classify "base" stream benchmarks by space usage 2020-02-21 16:32:46 +05:30
Harendra Kumar
7ce2dc87ea merge nested and nested-unfold benchmarks with others
merge them with other serial stream benchmarks.
2020-02-21 16:32:46 +05:30
Harendra Kumar
0b00efe4f6 Reorganize benchmark modules
* move common modules to lib directory. This is required because otherwise
  cabal/ghc would try to use them directly and emit warnings about
  missing-modules.

* move the prelude benchmark executables to Streamly/Benchmark/Prelude
  to be consistent with the organization of other modules.
2020-02-21 16:32:46 +05:30
Harendra Kumar
b50e1a5285 Add benchmarks for Foldable and Traversable 2020-02-19 16:58:23 +05:30
Harendra Kumar
4f4964afca Use less memory for single chunk chunksOf benchmark
So that we can limit the heap to a reasonable value in tests.

Also move the chunksOf benchmarks out of the DEVBUILD flag as they do not
depend on a well formed text file.
2020-02-14 17:50:58 +05:30
Harendra Kumar
54662d80c7 Add a predicate to pollCounts
The predicate provides more power to the combinator by allowing you to count
only certain elements in the stream and filter out others. This is efficient
compared to an async tap followed by a filter and fold as here filtering is
done on the source.
2020-02-10 16:09:16 +05:30
Harendra Kumar
d7d42be739 remove stale comment 2020-02-01 00:52:17 +05:30
Harendra Kumar
753d091b75 Refactor currentTime, add comments, safety notes 2020-01-27 16:38:34 +05:30
adithyaov
50548138d6 Add currentTime and its benchmarks 2020-01-27 16:38:34 +05:30
Harendra Kumar
868fc9f996 Fix benchmark build with "dev" flag for PrimArray 2020-01-26 13:49:05 +05:30
Harendra Kumar
cee86ffa42 Fix concatMapWith benchmarks measurement issue.
The problem got introduced inadvertently by commit
22bfa72599
2020-01-25 22:58:13 +05:30
adithyaov
9bab836f6c Change module structure for PrimArray
Data.PrimArray -> Data.Prim.Array
2020-01-25 15:39:59 +05:30
adithyaov
75b7e6b041 Add benchmarks for PrimArray 2020-01-25 15:39:57 +05:30
Harendra Kumar
a67e688c5d Use StreamD version of mergeBy in async merge
Now that we have StreamD version of mkParallel we should be able to use StreamD
version of merge efficiently.

Performance improved by 6x.
2020-01-25 15:32:27 +05:30
Harendra Kumar
26354ba701 normalize zip benches, add mergeAsyncByM benchmark
Do not use "tail" in zip benchmarks otherwise the tail perf can impact these
benchmarks. Also it makes them consistent with other such benchmarks.

Use half the stream size for each side of zip so that we effectively
create a stream of size similar to other linear benchmarks.
2020-01-22 16:02:39 +05:30
Pranay Sashank
00f541e6d5 Hide Streamly.Data.Array and Streamly.Data.SmallArray.
- Closes #378
2020-01-21 13:24:22 +05:30
Harendra Kumar
60cee489ae Add exception handling combinators with guaranteed cleanup
The "after", "finally" and "bracket" combinators did not run the "cleanup"
handler in case the stream is lazily partially evaluated e.g. using the lazy
right fold (foldrM), "Streamly.Prelude.head" is an example of such a fold.

Since we run the cleanup action when the stream Stops, the action won't be run
if the stream is not fully drained.

In the new implementation, we use a GC hook to run the cleanup action in case
the stream got garbage collected even before finishing. This will take care of
the lazy right fold cases mentioned above.
2020-01-18 15:02:34 +05:30
Harendra Kumar
22bfa72599 Add a middle point for concatMapWith benchmark
* We are testing two extreme cases, add a middle case as well where the outer
  and inner streams are of equal size.

* Enable some pure benchmarks as well

* Separate the zip benchmarks in a separate group as they are scalable
  (memory consumption does not increase with stream size) and parallel
  benchmarks are not scalable.
2020-01-16 18:50:30 +05:30
Harendra Kumar
290d2f6135 Make some updates to takeByTime/dropByTime
* Document the precise behavior, some changes were made to the earlier behavior
* Make some changes to implementation according to (newly) documented behavior
* TakeByTime: perform the time check before generating the element so that we
  do not drop an element after generation.
* TakeByTime now yields at least one element if the duration is non-zero
* dropByTime does not check the time after the drop duration is over
* Add inspection tests
* make the tests for shorter duration, earlier tests took too long
2020-01-16 02:02:37 +05:30
adithyaov
1979370373 Add takeByTime and dropByTime combinators 2020-01-16 02:02:37 +05:30
adithyaov
65ed762cbc Remove cpp-options that control length in linear*
* This includes linear, linear-async, linear-rate
* Modules removed: linear-long, linear-async-long
* CPP options removed: -DLINEAR_ASYNC
2020-01-08 18:15:43 +05:30
Harendra Kumar
5073377ba9 Add modular stream stats counting
* pollCounts to poll the element count in another thread
* delayPost to introduce a delay in polling
* rollingMap to compute diff of successive elements

These combinators can be used to compute and report the element
processing rate in a stream.
2019-12-31 00:22:41 +05:30
Harendra Kumar
90ce1596e3 Fix benchmark build broken by tapRate hiding 2019-12-28 00:42:30 +05:30
Pranay Sashank
d582037250 Add tapRate combinator.
- Also includes benchmarks for it.
2019-12-27 23:30:01 +05:30
Harendra Kumar
998f496af7 Add support for large streams in benchmarks
* Instead of using hard coded numbers scale them based on the stream size.
* Add concatMapWith benchmarks for concurrent streams
* Add a linear-async-long benchmark that works on streams of 10 million
  elements

We need large streams to detect memory leak issues. Specifically, we
could not figure out the concatMapWith memory leak issue without a
stream of at least 10s of millions of elements.

For long benchmarks we use gauge defaults so that we do not run many
iterations/samples.
2019-12-27 10:48:08 +05:30
Harendra Kumar
76c3f2b40f Reorganize prelude benchmarks
Keep related benchmark code together and try to keep the order in sync with
the Streamly.Prelude module.

This is purely a reorganization of code by moving related code together
and adding comments for subsections of code. There is no functionality
change at all.
2019-12-27 10:46:40 +05:30
Harendra Kumar
a00e05750a Add benchmark for tapAsync
StreamD style tapAsync is 2x faster than the previous implementation
2019-12-18 10:52:28 +05:30
Harendra Kumar
1baab0c104 Add benchmarks for tap/tapAsync 2019-12-18 10:52:28 +05:30
Harendra Kumar
617a9e738d disable inspection test for splitOnSeq
The change of StreamK/Type.serial impl makes this test fail because of IsStream
dictionary still being around. However, there is not much difference in the
actual benchmark results. And, serial impl change has other much better results
in other benchmarks.
2019-12-17 16:43:30 +05:30
adithyaov
ea875a020e Move Benchmark* to benchmark/ + Rm benchmark flag 2019-12-17 13:00:09 +05:30
Pranay Sashank
f44543bc8f Add benchmarks for SmallArray. 2019-12-12 14:03:43 +05:30
Pranay Sashank
42f1091826 Add more benchmarks to unpinned-array. 2019-12-04 13:41:55 +05:30
Pranay Sashank
3b9b8d1baf Add benchmarks for Streamly.Data.Array. 2019-12-04 13:41:55 +05:30