diff --git a/README.md b/README.md index 8f5ec86..3ea5515 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Parallel coroutine operations on Kotlin collections -Provides parallelized map, ~~reduce~~, ~~etc.~~ operations using coroutines in Kotlin. +Provides parallelized map, reduce, etc. operations using coroutines in Kotlin. At this point, there is only a parallel map implementation called .mapParallel(). It is implemented like this. ```kotlin @@ -19,6 +19,17 @@ fun showCase() { ``` If you want to achieve multithreading, make sure to run the coroutine with the Default dispatcher. +## Chunked operations +Chunked operations improve performance since they split the collection into just a couple of segments, +which are processed each by a single thread. That benefits from data locality and lesser thread management. +It is particularly useful (pretty much needed for operations like sum) in the reduce operation when using multithreading, +since each thread takes one chunk that it reduces on its own. After all threads finish, their results are then reduced again to the final result. + +## Benchmarks +This source includes some benchmarks in the test source folder using [JUnitBenchmarks](http://labs.carrotsearch.com/junit-benchmarks-tutorial.html). Performance of the methods (chunked vs. not chunked and Dispatcher.Default vs Dispatcher.Main) depends on the type of the transformation operation (whether it's blocking for a long time, suspending or really quick). + +Example benchmarks will be included here soon. + ## Gradle To include this in you gradle project add the following to you root build.gradle file. ```gradle @@ -37,7 +48,4 @@ dependencies { ``` ## Future -In the future, I would like parallel reduce and other transformation functions to be implemented, -as well as chunked variations of the map and future operations. -Chunked operations could potentially improve performance since they would split the collection into just a couple of segments, -which would be processed each by a single thread. That could benefit from data locality and lesser thread management. +In the future, I would like other transformation functions to be implemented.