Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP: introduce Scope to Iterant encoding * Encode resource using Ref; fix Scope concat. * Change encoding * Update to Cats-Effect 1.0.0-RC2 * Fix onErrorHandle and attempt * 18/19 MapBatch * Fixed attempt/onErrorHandleWith * IterantFoldLeft progress Signed-off-by: Piotr Gawryś <pgawrys2@gmail.com> * Restore `Iterant#map` tests * Fix Iterant#zipWithIndex * Restore `Iterant#collect` tests * Fix Iterant#drop * Fix Iterant#bufferSliding and batched * fix IterantDropWhile * Fix Iterant#filter * Fix Iterant#liftMap * Restore tests for Iterant#mapEval * Fix Iterant#skipSuspendL * Fix Iterant#headOptionL * Fix Iterant#take and Iterant#scan * Restore fromIndexedSeq, fromIterable, fromList Signed-off-by: Avasil <pgawrys2@gmail.com> * Remove Iterant#skipSuspendL * Fix `guarantee` with `Iterant#take` * Fix Iterant#distinctUntilChanged{ByKey} * Fix IterantDropWhile * Fix Iterant#dropLast * Fix Iterant#foldWhileLeft{Eval}L * Fix Iterant#intersperse * Fix Iterant#reduce * Fix IterantTakeWhile * Fix IterantTakeWhileWithIndex * Fix IterantDropWhileWithIndex * Remove Iterant's DoOnEarlyStop / DoOnFinish tests * Fix IterantDump * Restore Iterant FromSeq, FromStateAction, Ranges suites * IterantDump handle concat/scope like suspend * Introduce the visitor pattern * Fix IterantTakeLast * Refactor Iterant.foldLeft to use Visitor * Restore Iterant#scanMap suite * Refactor Iterant.map, add benchmark * Restore Iterant#scanEval * Optimize Concat * Cleanup junk from Iterant.concat * Fix IterantRepeat * Refactor Iterant#collect * Refactor Iterant.completeL * Refactor Iterant#distinctUntilChanged * Fixed Iterant#drop, refactored Iterant#distinctUntilChanged * Remove stack from Iterant.drop implementation * Remove stack from Iterant.distinctUntilChanged implementation * Refactor Iterant.dropLast * Refactor Iterant.dropWhile, Iterant.filter * Refactor Iterant.dropWhileWithIndex + dump * Fix Iterant.foldRightL * Refactor Iterant.foldWhileLeft * Refactor Iterant.mapBatch * Refactor Iterant.mapEval * Refactor Iterant.liftMap * Add AndThen tests * Remove AndThen for now * Refactor Iterant.attempt and onErrorHandleWith * Iterant.reduce refactoring * Refactor IterantScanEval * Refactor Iterant.headOptionL * Iterant.switchIfEmpty fix * Refactor Iterant.tail * Refactor Iterant.take * Refactor Iterant.takeLast * Refactor Iterant.takeEveryNth * Refactor Iterant.takeWhile * Refactor Iterant.takeWhileWithIndex * Change Iterant.Scope to Iterant.Resource w/ new encoding * Fix Iterant.attempt + onErrorHandleWith * Fix Iterant.foldWhileLeftL * Fix Iterant folds * Fix Iterant.dump test * Rename Resource back to Scope * Reintroduce stack usage in Iterant.foldLeftL * Fix Iterant.completeL + foldLeftL + foldWhileLeftL * Refactor Iterant.headOptionL * Refactor Iterant.foldRight * Fix Iterant.zip, zipMap and parZipMap, parZip * Remove junk * Fix Iterant.interleave * Fix Iterant.interleave * Fix Iterant.toReactivePublisher * Fix Iterant.toReactivePublisher * Partial fromReactiveStream implementation * Change Iterant.fromReactivePublisher * Fix tests * Fix tests, builders * Fix Mima issues * Fix Scala 2.12.6 warning
- Loading branch information
Showing
122 changed files
with
6,270 additions
and
4,819 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
benchmarks/shared/src/main/scala/monix/benchmarks/IterantMapFoldBenchmark.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (c) 2014-2018 by The Monix Project Developers. | ||
* See the project homepage at: https://monix.io | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package monix.benchmarks | ||
|
||
import java.util.concurrent.TimeUnit | ||
import monix.eval.Coeval | ||
import monix.tail.Iterant | ||
import org.openjdk.jmh.annotations._ | ||
|
||
/** To do comparative benchmarks between versions: | ||
* | ||
* benchmarks/run-benchmark IterantMapFoldBenchmark | ||
* | ||
* This will generate results in `benchmarks/results`. | ||
* | ||
* Or to run the benchmark from within SBT: | ||
* | ||
* jmh:run -i 10 -wi 10 -f 2 -t 1 monix.benchmarks.IterantMapFoldBenchmark | ||
* | ||
* Which means "10 iterations", "10 warm-up iterations", "2 forks", "1 thread". | ||
* Please note that benchmarks should be usually executed at least in | ||
* 10 iterations (as a rule of thumb), but more is better. | ||
*/ | ||
@State(Scope.Thread) | ||
@BenchmarkMode(Array(Mode.Throughput)) | ||
@OutputTimeUnit(TimeUnit.SECONDS) | ||
class IterantMapFoldBenchmark { | ||
import IterantMapFoldBenchmark._ | ||
|
||
@Benchmark | ||
def granular(): Long = | ||
granularRef.map(_ + 1).foldLeftL(0L)(_ + _).value | ||
|
||
@Benchmark | ||
def batched(): Long = | ||
batchedRef.map(_ + 1).foldLeftL(0L)(_ + _).value | ||
} | ||
|
||
object IterantMapFoldBenchmark { | ||
val size = 1000 | ||
|
||
val granularRef: Iterant[Coeval, Int] = { | ||
var stream = Iterant[Coeval].empty[Int] | ||
var idx = 0 | ||
while (idx < size) { | ||
stream = idx +: stream | ||
idx += 1 | ||
} | ||
stream | ||
} | ||
|
||
val batchedRef: Iterant[Coeval, Int] = { | ||
var stream = Iterant[Coeval].empty[Int] | ||
var idx = 0 | ||
while (idx < size) { | ||
val rest = stream | ||
stream = rest ++ Iterant[Coeval].range(0, 10) | ||
idx += 1 | ||
} | ||
stream | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
monix-eval/shared/src/test/scala/monix/eval/TestUtils.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (c) 2014-2018 by The Monix Project Developers. | ||
* See the project homepage at: https://monix.io | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package monix.eval | ||
|
||
import java.io.{ByteArrayOutputStream, PrintStream} | ||
import scala.util.control.NonFatal | ||
|
||
/** | ||
* INTERNAL API — test utilities. | ||
*/ | ||
trait TestUtils { | ||
|
||
/** | ||
* Silences `System.err`, only printing the output in case exceptions are | ||
* thrown by the executed `thunk`. | ||
*/ | ||
def silenceSystemErr[A](thunk: => A): A = synchronized { | ||
// Silencing System.err | ||
val oldErr = System.err | ||
val outStream = new ByteArrayOutputStream() | ||
val fakeErr = new PrintStream(outStream) | ||
System.setErr(fakeErr) | ||
try { | ||
val result = thunk | ||
System.setErr(oldErr) | ||
result | ||
} catch { | ||
case NonFatal(e) => | ||
System.setErr(oldErr) | ||
// In case of errors, print whatever was caught | ||
fakeErr.close() | ||
val out = outStream.toString("utf-8") | ||
if (out.nonEmpty) oldErr.println(out) | ||
throw e | ||
} | ||
} | ||
|
||
/** | ||
* Catches `System.err` output, for testing purposes. | ||
*/ | ||
def catchSystemErr(thunk: => Unit): String = synchronized { | ||
val oldErr = System.err | ||
val outStream = new ByteArrayOutputStream() | ||
val fakeErr = new PrintStream(outStream) | ||
System.setErr(fakeErr) | ||
try { | ||
thunk | ||
} finally { | ||
System.setErr(oldErr) | ||
fakeErr.close() | ||
} | ||
outStream.toString("utf-8") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...ecution/js/src/main/scala/monix/execution/internal/DefaultUncaughtExceptionReporter.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (c) 2014-2018 by The Monix Project Developers. | ||
* See the project homepage at: https://monix.io | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package monix.execution | ||
package internal | ||
|
||
import scala.concurrent.ExecutionContext | ||
|
||
/** | ||
* INTERNAL API — implements [[UncaughtExceptionReporter.default]]. | ||
*/ | ||
private[execution] object DefaultUncaughtExceptionReporter | ||
extends UncaughtExceptionReporter { | ||
|
||
def reportFailure(e: Throwable): Unit = | ||
logger(e) | ||
|
||
private[this] lazy val logger = | ||
ExecutionContext.defaultReporter | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...cution/jvm/src/main/scala/monix/execution/internal/DefaultUncaughtExceptionReporter.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2014-2018 by The Monix Project Developers. | ||
* See the project homepage at: https://monix.io | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package monix.execution | ||
package internal | ||
|
||
/** | ||
* INTERNAL API — implements [[UncaughtExceptionReporter.default]]. | ||
*/ | ||
private[execution] object DefaultUncaughtExceptionReporter | ||
extends UncaughtExceptionReporter { | ||
|
||
def reportFailure(e: Throwable): Unit = | ||
Thread.getDefaultUncaughtExceptionHandler match { | ||
case null => e.printStackTrace() | ||
case h => h.uncaughtException(Thread.currentThread(), e) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.