Commit Graph

359 Commits

Author SHA1 Message Date
Harendra Kumar
7e4b43ceff Add adaptive benchmark, report cpuTime as well 2020-02-14 17:50:58 +05:30
Harendra Kumar
5f86fd374b Add documentation, format code, use forkIO for baseline 2020-02-14 17:50:28 +05:30
Harendra Kumar
03ff90eb9b Add bench-show comparison for array benchmarks 2020-02-13 18:36:05 +05:30
Harendra Kumar
2604246b63 update missing benchmarks, support benchmark groups
Support running groups of benchmarks e.g. ARRAY/SERIAL/CONCURRENT
Add missing array benchmarks and "parallel" benchmark
For "--long" case run only INFINITE stream benchmarks
2020-02-13 18:36:05 +05:30
Harendra Kumar
e90c0fa775 Move WAsync to finite stream benchmarks
WAsync is finite by nature, so it cannot run with finite resources on large
or infinite streams.
2020-02-13 18:36:05 +05:30
Harendra Kumar
65ca1481b4 Restrict the stream size to default for buffered ops
Buffered operations cannot scale to infinite or large streams.
2020-02-11 18:12:19 +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
385f0fc152 Remove number of elements from bench descr
Number elements may be incorrect if the stream size is specified on the command
line. Also it becomes inconsistent if changes are made to the defaults in the
benchmarks.
2020-01-25 15:32:27 +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
f5c55df294 separate "parallel" style benchmarks
As they are not "streaming" and take much longer compared to other concurrent
streams.
2020-01-18 03:06:08 +05:30
Harendra Kumar
fdf7e1fdf9 increase the stream size for linear-async benchmarks
This is to make it the same as other benchmarks. We had to change the size of
the extreme concatMapWith benchmark to keep it in reasonable time limits.
2020-01-16 18:50:30 +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
afc02e6970 separate const mem benchmarks from buffered ones
Streaming benchmarks take constant memory whereas the buffering ones take
memory proportional to the stream size. We would like to test them separately.
For streaming benchmarks we can use a very large stream size to make sure there
is no space leak and we are running in constant memory for long time.
2020-01-16 18:50:30 +05:30
Harendra Kumar
880a0729ea Run long benchmarks before release 2020-01-16 18:43:26 +05:30
Harendra Kumar
71f61967ee rename nestedUnfold to nested-unfold 2020-01-16 02:25:10 +05:30
Harendra Kumar
eedd741499 pass stream-size from CLI for nested-unfold 2020-01-16 02:25:10 +05:30
Harendra Kumar
54a1fc770a pass stream-size parameter to child process
gauge --measure-with forks a child process for each benchmark. The options
passed to the main gauge process are not passed to the child process. We use an
environment variable to set the stream-size and pass it on to the child
process.
2020-01-16 02:25:10 +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
Harendra Kumar
ef958917ee use "seq" on "value"
It improves many benchmarks significantly.
2020-01-08 18:15:43 +05:30
Harendra Kumar
8ec2ebe188 Accept stream size via a CLI option
Use --stream-size to accept the stream size.  The CLI argument position
is not fixed anymore so it can be specified anywhere on the command line. The
remaining arguments are used by gauge.
2020-01-08 18:15:43 +05:30
adithyaov
f684e266af Remove cpp-options that control length in nested*
* This includes nested, nested-concurrent
* Modules removed: nested-concurrent-long
* CPP options removed: -DLONG_BENCHMARKS
2020-01-08 18:15:43 +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
ff99b4c1d0 Add nested-concurrent benchmark 2020-01-04 16:43:54 +05:30
adithyaov
5faf292267 Mv bemchmarks & change INLINABLE to INLINE - lastN
* Move benchmarks of lastN under serially/fold
* Changing INLINEABLE to INLINE on lastN allows fusion, increasing the perf
2020-01-02 16:51:43 +05:30
adithyaov
46643d15b3 Add lastN combinator 2020-01-02 16:51: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
adithyaov
d6afd92d98 Add rollingHashFirstN, drainN and drainWhile 2019-12-30 15:57:34 +05:30
adithyaov
511fe85cc6 Use StreamD for iterate and iterateM 2019-12-30 15:37:03 +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
5949f4c15d Add large stream benchmarks for linear/nested-concurrent 2019-12-27 10:48:09 +05:30
Harendra Kumar
17a30053e2 separate concurrent nested benchmarks from serial
We want to use -threaded and -N2 options for concurrent benchmarks.
2019-12-27 10:48:09 +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
Harendra Kumar
1dcad0f560 improve perf of functor and applicative instances
Functor instances of various stream types are directly expressed in terms of
StreamD map impl.

Applicative instances now use concatMap instead of using "ap" from Monad.

Rewrite rules to specialize unfoldrM to WSerial and ZipSerial as well so
that it performs well for those. This was causing benchmarks for these
to be much slower beacause of unfoldrM used in the benchmarks being
slow.  For this, I had to move the zipWith* impls into the Zip module so
that we can import the ZipSerial type in Prelude.
2019-12-17 14:27:58 +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
adithyaov
6a593ebe85 Move Streams/Prelude.hs to Internal/Data/Stream 2019-12-09 15:59:34 +05:30
adithyaov
1790841a34 Move Streams/StreamDK* to Internal/Data/Stream 2019-12-09 15:23:36 +05:30
adithyaov
70c03f97bf Move Streams/StreamK* to Internal/Data/Stream 2019-12-09 15:14:05 +05:30
adithyaov
59796f1d14 Move Streams/StreamD.hs to Internal/Data/Stream/* 2019-12-09 14:56:10 +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
Harendra Kumar
107f52718f Add benchmarks for parallel application and fold 2019-11-21 21:43:41 +05:30
Harendra Kumar
90da32549d Fix build with "dev" flag 2019-11-21 20:37:47 +05:30
adithyaov
2c9503769c Move the Benchmark.* modules to Internal 2019-11-19 15:40:41 +05:30
Harendra Kumar
9ad7fca9c7 Add inner monad transformations 2019-11-10 04:00:33 +05:30
Harendra Kumar
8351c936c3 Add hoist and generally for streams 2019-11-10 04:00:33 +05:30
Pranay Sashank
fa1318e57f Update maintainer email to streamly@composewell.com. 2019-11-07 12:31:07 +05:30
Harendra Kumar
011299be70 rename Unicode encode/decode ops
* refactor the Unicode stream module in Stream/Char/Array modules
2019-11-04 02:54:46 +05:30
Harendra Kumar
a9f3f9a0fb Add unfoldWords/interpose/intercalate etc.
* Rearrange, update benchmarks for words/unwords, lines/unlines
* Add interpose/intercalate/interleaveInfix/interleaveSuffix to Prelude
* Add unfoldWords to Data.String

Use the newly added rotuines to write words/unwords and lines/unlines more
idiomatically and with improved performance.
2019-10-24 02:58:28 +05:30
Harendra Kumar
fbec11f24d Use foldr/build fusion for toList 2019-10-19 23:49:13 +05:30
Harendra Kumar
1266a13e0e Add "concurrent" benchmark to charting/bench-show 2019-10-16 14:24:03 +05:30
Harendra Kumar
3093e7934a change "handle" to produce streams in exception case
Also implement gbracket for generalized exception handling/bracketing
2019-10-15 00:40:15 +05:30
Harendra Kumar
1305145e06 Add benchmarks for exception handling operations 2019-10-15 00:40:15 +05:30
Harendra Kumar
e25db62db7 Add INLINE annotation on "onArray" 2019-10-15 00:40:15 +05:30
Harendra Kumar
51f12c9d22 Use unfolds to read from file handles 2019-10-15 00:40:15 +05:30
Harendra Kumar
58d1d61afd Use unfolds instead of streams for array reading 2019-10-15 00:40:15 +05:30
Harendra Kumar
16c2f015c2 rename "runFold" to "fold"
* we are using "unfold" for unfolding, runUnfold is longer and sounds a bit
  weird. So similar to "unfold" we should use "fold" for folding.
* Another reason is that "runFold" sound ends in "unfold" so can sound
  confusing.
2019-09-29 14:52:29 +05:30
Harendra Kumar
4810c8eef6 Add nested unfold operations and benchmarks
Especially add chaining of unfolds and outerProduct operations. outerProduct is
just the cartesian product of two streams, it is like the concatMap/bind for
streams. In contrast to concatMap, the unfold nested looping operations are
amenable to complete fusion providing us amazing performance equivalent to
linear stream operations.
2019-09-29 01:37:22 +05:30
Harendra Kumar
8fbb4d4227 enable pipe/sink/list benchmarks 2019-09-26 01:05:15 +05:30
Harendra Kumar
3c8f5b8096 move Sink module files to Internal 2019-09-25 17:17:48 +05:30
Harendra Kumar
631cc24fec move file SVar.hs to Internal/Data 2019-09-25 17:17:47 +05:30
Harendra Kumar
98393fc44a move pipe module files to Internal 2019-09-25 17:17:47 +05:30
Harendra Kumar
1475c2fb7d Move Streamly.Unfold to Streamly.Internal.Data.Unfold 2019-09-24 21:28:25 +05:30
Harendra Kumar
ae847b821f remove fold API exports from Streamly.Internal
They are now exported via Streamly.Internal.Data.Fold
2019-09-24 21:14:51 +05:30
Harendra Kumar
042b677592 Move Streamly.Fold module
* Move exposed Streamly.Fold to Streamly.Data.Fold
* Move the internal implementation to Streamly.Inetrnal.Data.Fold
2019-09-24 21:14:51 +05:30
Harendra Kumar
ee6be006b2 Stop exposing internal Prelude functions via Internal
They are now exposed via Internal.Prelude
2019-09-24 20:55:41 +05:30
Harendra Kumar
6b98e076d2 Fix build with "dev" flag 2019-09-24 20:55:31 +05:30
Harendra Kumar
9e46ec65fc Add some tests and benchmarks for decode-utf8 2019-09-19 08:59:59 +05:30
Harendra Kumar
f5d83bc866 Add benchmark for decodeUtf8Lenient 2019-09-19 08:59:59 +05:30
Harendra Kumar
661f84262e Add some word/unword, word counting benchmarks 2019-09-15 23:48:21 +05:30
Harendra Kumar
307fa9f5d5 Add direct style append/interleave/concatUnfoldInterleave etc 2019-09-04 13:03:07 +05:30
Harendra Kumar
cccc7a4f34 Add a direct style version of StreamK 2019-08-30 13:43:27 +05:30
Harendra Kumar
379732da24 use bench-show 0.3 2019-08-27 23:34:35 +05:30
Harendra Kumar
6f06bdd7fe move the concatMap inspection test to benchmarks 2019-08-27 21:29:57 +05:30
Harendra Kumar
0ef35be05b Add inspection tests for some benchmarks (eq/cmp/merge/zip) 2019-08-23 17:43:00 +05:30
Harendra Kumar
11b10b9c0c Move LinearOps.hs benchmark file to streamly library
To facilitate inspection testing of all benchmarks.
2019-08-23 14:57:29 +05:30
Harendra Kumar
17b7d92941 correct test description 2019-08-23 06:27:51 +05:30
Harendra Kumar
120175cb64 Add inspection testing for fileio benchmarks 2019-08-20 08:19:49 +05:30
Harendra Kumar
da29139f45 Use Unfold to read and concat arrays efficiently
The performance is similar to flattenArrays, the code fuses perfectly. But in
the linecount benchmark Unfold case performs 50% slower even though this is not
due to fusion, just less optimal code being generated.
2019-08-19 13:33:24 +05:30
Harendra Kumar
3b0f6df5cf Add an unfold type to compose streams with better fusion 2019-08-17 14:04:06 +05:30
Harendra Kumar
1bfca9e46c merge the ArrayStream module to Array module itself
Each container type (e.g. Handle/Socket/File) may have similar nested/stream
level operations. We need a standardized way of naming the combinators related
to streams of containers.  Also, we cannot have a separate module for such
combinators for each container type. Therefore it makes sense to put them in
the same module.
2019-08-17 05:13:48 +05:30
Pranay Sashank
d26ab21364 Move Streamly.String to Streamly.Data.String. 2019-08-13 13:09:22 +05:30
Pranay Sashank
5b801ab335 Flip the arguments order to foldLines and foldWords. 2019-08-12 09:53:01 +05:30
Harendra Kumar
479d731b24 Add writeS to fileio benchmarks 2019-08-12 07:13:26 +05:30
Harendra Kumar
06b0cb1328 Implement IO write operations as folds. 2019-08-12 07:13:26 +05:30
Harendra Kumar
3d32be5acc Add array benchmarks to charting/comparisons 2019-08-12 07:13:26 +05:30
Harendra Kumar
1e6b3b6261 Expose hidden Prelude APIs via Streamly.Internal module 2019-08-07 03:44:02 +05:30
Harendra Kumar
27d7ea8f30 expose the experimental Fold APIs via internal module 2019-08-07 03:42:56 +05:30
Pranay Sashank
07e954820d Refactor readArraysOfUpto to readArraysOf in Socket, Handle, File.
- And also in examples, benchmarking code.
2019-08-07 00:22:26 +05:30
Pranay Sashank
bda6a6415b Refactor modules Mem.* ~> Memory.* and update references. 2019-08-06 04:31:23 +05:30
Harendra Kumar
2438be4259 rename the Mem.Array.Stream module to Mem.ArrayStream 2019-08-06 02:55:06 +05:30
Harendra Kumar
e621237b79 update documentation and rename toArray => write
rename toArray/toArrayN to writeF/writeNF to keep the API name consistent with
their regular counterparts. Now the only difference in fold APIs is a suffix F.
2019-08-06 02:28:14 +05:30
Harendra Kumar
a740d4dba9 move stream transformation operations to Prelude 2019-08-03 23:15:26 +05:30
Harendra Kumar
3cdecba40c Create a separate module for "Streams of Arrays" 2019-08-03 08:16:23 +05:30
Harendra Kumar
196b4de2ed hide benchmarks for hidden combinators 2019-08-03 05:16:59 +05:30
Pranay Sashank
f8afec67f4 Comment out benchmarking code for pipes ops. 2019-07-30 15:05:24 +05:30
Harendra Kumar
687fb9a283 Add "flatten" to StreamD as a faster alternative to concatMap 2019-07-28 06:43:51 +05:30
Harendra Kumar
8552589390 Add more concatMap benchmarks
* concat pure streams
* concat n x n
* use replicate with concatMap
2019-07-26 19:18:00 +05:30
Harendra Kumar
b67b840556 Add config options to run benchmarks quickly 2019-06-28 03:16:46 +05:30
Harendra Kumar
d6eb138165 Add concat/append benchmark for concurrent streams
Measure space usage in interesting cases.

The motivation for these benchmarks is parallel stream consuming a lot of stack
space in concatMap case. These benchmarks will hopefully catch any such
problems in future.

These benchmarks may take a lot of time to allow memory consumption to slowly
buildup to noticeable amount in case there is a problem. Therefore they are
enabled only in dev builds. We can use `--include-first-iter`, `--min-duration
0` options in gauge to run them in reasonable time. They need to be run with
`--measure-with` option to allow isolated runs, otherwise memory measurement
won't be correct.
2019-06-28 02:54:35 +05:30
Harendra Kumar
50170f39a5 Add fileio benchmark 2019-06-18 23:39:15 +05:30
Harendra Kumar
773f5a7c70 Fix a bug that caused reopening of the wrong file 2019-06-18 16:19:00 +05:30
Harendra Kumar
b846fd6a21 Allow older versions of deepseq
Otherwise cabal cannot find a build plan for older versions of GHC
2019-06-16 19:39:46 +05:30
Harendra Kumar
a8051edf7a Add cat and wc -l to benchmarks 2019-06-16 19:39:37 +05:30
Harendra Kumar
213ac6bc98 use the same test file for all benchmarks 2019-06-16 19:39:26 +05:30
Harendra Kumar
dbaacea1c6 implement fromStreamDArraysOf more efficiently
The implementation of fromStreamDArraysOf is now 3x more efficient compared to
the earlier implementation. This makes byte stream level operations almost as
efficient as array level operations.

Other than this the following changes are added in this commit:
* Add insertAfterEach
* Add writeArraysPackedUpto to Handle IO
* Implement `wc -l` example more efficiently using arrays
* Add benchmark for lines/unlines using arrays
* Add tests for splitArraysOn
* Rename some array/file/handle APIs
* Error handling when the group size in grouping operations is 0 or negative
2019-06-15 19:01:09 +05:30
Harendra Kumar
694eab4e6a Raw IO w/o buffering, add some array APIs
* Streamly.FileSystem.FD module for unbuffered IO. Buffering can be controlled
  from the stream itself.
* Support IO using writev as well

Array APIs include:

* coalesceChunksOf to coalesce smaller arrays in a stream into bigger ones
* unlinesArraysBy to join a stream of arrays using a line separator
* splitArraysOn to split a stream of arrays on a separator byte
2019-06-15 19:01:09 +05:30
Pranay Sashank
2255dacd3e Add benchmarking code for lines/unlines, decode/encode. 2019-06-12 10:38:55 +05:30
Pranay Sashank
d4bef2e352 Add intersperse to Streamly.Prelude.
- Also adds benchmarking code for intersperse.
2019-06-12 10:30:15 +05:30
Harendra Kumar
98d225672d Rename merge to tee 2019-06-07 09:34:23 +05:30
Harendra Kumar
517c3b7a23 Implement a 'Pipe' type 2019-06-07 09:34:23 +05:30
Pranay Sashank
218b48a1a3 Add benchmarks for fromIndices and fromIndicesM. 2019-06-01 22:00:04 +05:30
Harendra Kumar
606fe9de74 rename FileSystem.File module to FileSystem.Handle 2019-05-30 08:31:24 +05:30
Harendra Kumar
1949eb90af Concurrent concatMap, foldr/build fusion, benchmarks
* Implement a stream flavor specific (concurrent/wSerial etc.) concatMap
  (concatMapBy). Now concatMap has the same capabilities that the monad bind of
  different streams has. In fact the monad bind is implemented using concatMap

* Use foldr/build fusion for concatMap (currently disabled) and for map/fmap
  and mapM (enabled)

* Add benchmarks for bind/concatMap performance
2019-05-27 23:29:21 +05:30
Harendra Kumar
50232af000 rename/reorg/remove some fold APIs
rename groupsOf to chunksOf
remove grouped as it is just another version of splitSuffixBy'
reorganize sections
Add some docs/notes
2019-05-20 00:57:16 +05:30
Harendra Kumar
8bcbc77e62 rename Streamly.Array to Streamly.Mem.Array 2019-05-15 20:41:45 +05:30
Harendra Kumar
38c5c8872c Add File IO support 2019-05-15 17:54:12 +05:30
Harendra Kumar
7336d585a9 Fix a bug caused by unsafeInlineIO
unsafe use of unsafeInlineIO caused each array allocated in the toArrayN fold
to share the same memory.

This fix uses the IO monad to make sure that the code is not pure and therefore
we always allocate new memory. All such usage of unsafePerformIo have been
fixed. The remaining ones are reviewed to be safe.
2019-05-13 12:21:16 +05:30
Harendra Kumar
fd7bd713ec Add "Streamly.Fold" module 2019-05-13 12:21:16 +05:30
Harendra Kumar
36c4c4ca7b Add Streamly.Array module
* Supports fixed size immutable arrays
* See the module documentations for details.
2019-05-13 12:21:16 +05:30
Harendra Kumar
db2c560a65 add direct versions of monolithic scan/map and fold/map
After perf measurement these seems to perform the same as a scan followed by
map therefore we have not exposed these but kept for perf comparison and just
in case use.

* Deprecate `scanx`, `foldx`, `foldxM`
* Remove deprecated APIs `scan`, `foldl`, `foldlM`
2019-05-04 15:35:55 +05:30
Harendra Kumar
f1670f31ce Move some functions from Streamly to Streamly.Prelude
* `runStream`, `foldWith`, `foldMapWith`, `forEachWith` have been moved from
  "Streamly" module to "Streamly.Prelude" module.
2019-05-04 02:42:38 +05:30
Harendra Kumar
0ce4a6d5ad Fix right fold, document folds, add generic folds
* Fix the signature of foldrM
* Implement some custom folds in terms of foldr
* Document folds and scans better
* Reorganize the documentation in Prelude
* Add foldrS and foldrT for transforming folds
* add toRevList
* Add benchmarks and tests for the new folds
2019-05-03 16:46:43 +05:30
Harendra Kumar
7d577a469b Add detailed benchmarks for folds
INLINE foldlM'
2018-12-29 21:10:02 +05:30
Harendra Kumar
aaf8d2c45b Fixup after merge with master 2018-12-29 17:24:18 +05:30
Harendra Kumar
d08c057f8f Add Enumerable type class 2018-12-29 16:22:29 +05:30
Harendra Kumar
d01942d9dd Add applicative benchmarks
Specialize asyncly/wAsyncly/aheadly applicative instances
2018-12-29 15:23:47 +05:30
Harendra Kumar
ede29df8d0 specialize the typeclass instances to recover performance 2018-12-28 12:25:52 +05:30
Harendra Kumar
9c8a7504fa Add mapM_ benchmark, add build/augment 2018-12-27 13:59:25 +05:30
Harendra Kumar
a30ef3eef9 Add a nano benchmark for unfoldr, fix dev benchmarks 2018-12-27 00:52:33 +05:30
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
Pranay Sashank
de083af8e7 Group merging and subsequences benchmarks. 2018-11-22 10:17:15 +05:30
Pranay Sashank
dbcf5363e8 Add isPrefixOf, isSubsequenceOf, stripPrefix to Prelude, StreamD. 2018-11-22 10:03:00 +05:30
Pranay Sashank
55e582efaf INLINE insert and delete in benchmarks. 2018-11-22 10:02:04 +05:30