Skip to content

Instantly share code, notes, and snippets.

View SampleTest.java
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import io.reactivex.Observable;
public class SampleTest {
@Test
public void test() throws Exception {
View ScrabbleDirect729.txt
Benchmark Mode Cnt Score Error Units
ShakespearePlaysScrabbleWithDirect.measureThroughput sample 8822 5,666 � 0,021 ms/op
ShakespearePlaysScrabbleWithDirect.measureThroughput:measureThroughput�p0.00 sample 4,948 ms/op
ShakespearePlaysScrabbleWithDirect.measureThroughput:measureThroughput�p0.50 sample 5,546 ms/op
ShakespearePlaysScrabbleWithDirect.measureThroughput:measureThroughput�p0.90 sample 6,291 ms/op
ShakespearePlaysScrabbleWithDirect.measureThroughput:measureThroughput�p0.95 sample 6,578 ms/op
ShakespearePlaysScrabbleWithDirect.measureThroughput:measureThroughput�p0.99 sample 8,344 ms/op
ShakespearePlaysScrabbleWithDirect.measureThroughput:measureThroughput�p0.999 sample 10,576 ms/op
ShakespearePlaysScrabbleWithDirect.measureThroughput:measureThroughput�p0.9999 sample 17
View Rx.NET_Release_4_1_0_old.md

NuGet: 4.1.0

>PM Install-Package System.Reactive -Version 4.1.0

Version 4.1.0 is an enhancement version over 4.0.0 by keeping the public API and extending it additively as well as having significant internal changes for better performance via less allocation, less indirection and less locking on the existing components. Note that the codebase now uses C# 7.1 language features.

API enhancements

  • Pull 486: Add the RetryWhen operator.
  • Pull 497: Add the IConnectableObservable.AutoConnect() operator.
  • Pull 536: Add the RepeatWhen operator.
View FlowComparison.java
package io.reactivex;
import java.util.concurrent.*;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import io.reactivex.internal.util.Pow2;
import io.reactivex.schedulers.Schedulers;
import io.reactivex.subjects.PublishSubject;
View subjects_comparison.txt
BenchmarkDotNet=v0.10.14, OS=Windows 10.0.17134
Intel Core i7-4790 CPU 3.60GHz (Haswell), 1 CPU, 8 logical and 4 physical cores
Frequency=3513591 Hz, Resolution=284.6091 ns, Timer=TSC
[Host] : .NET Framework 4.6.2 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.3110.0
DefaultJob : .NET Framework 4.6.2 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.3110.0
#### Current
Method | N | M | Mean | Error | StdDev | Median | Gen 0 | Gen 1 | Gen 2 | Allocated |
-------------------- |-------- |-- |------------------:|------------------:|------------------:|------------------:|----------:|----------:|----------:|----------:|
View ComparisonBenchmark.txt
BenchmarkDotNet=v0.10.14, OS=Windows 10.0.17134
Intel Core i7-4790 CPU 3.60GHz (Haswell), 1 CPU, 8 logical and 4 physical cores
Frequency=3513587 Hz, Resolution=284.6094 ns, Timer=TSC
[Host] : .NET Framework 4.6.2 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.3110.0
DefaultJob : .NET Framework 4.6.2 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.3110.0
#### Current sources
Method | N | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
------------------------------- |-------- |----------------------:|------------------:|------------------:|-----------:|----------:|----------:|------------:|
View Scrabble-dotnet-0705.txt
BenchmarkDotNet=v0.10.14, OS=Windows 10.0.17134
Intel Core i7-4790 CPU 3.60GHz (Haswell), 1 CPU, 8 logical and 4 physical cores
Frequency=3513587 Hz, Resolution=284.6094 ns, Timer=TSC
[Host] : .NET Framework 4.6.2 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.3110.0
DefaultJob : .NET Framework 4.6.2 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.3110.0
Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Allocated |
---------------- |-----------:|----------:|----------:|-----------:|---------:|----------:|
AsyncEnum | 144.332 ms | 0.5284 ms | 0.4684 ms | 12562.5000 | - | 50.32 MB |
View ComparisonAsyncBenchmark.txt
BenchmarkDotNet=v0.10.14, OS=Windows 10.0.17134
Intel Core i7-4790 CPU 3.60GHz (Haswell), 1 CPU, 8 logical and 4 physical cores
Frequency=3513584 Hz, Resolution=284.6097 ns, Timer=TSC
[Host] : .NET Framework 4.6.2 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.3110.0
DefaultJob : .NET Framework 4.6.2 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.3110.0
Method | N | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
--------------------- |-------- |---------------:|--------------:|--------------:|------------:|----------:|----------:|-------------:|
ObserveOn | 1 | 4.307 us | 0.0770 us | 0.0720 us | 0.9079 | - | - | 3.74 KB |
View RxEventBus.java
import java.util.*;
import rx.*;
import rx.Observable.Operator;
import rx.Observable;
import rx.observers.TestSubscriber;
import rx.subjects.*;
public class RxEventBus<T> {
View TimeoutExample.java
Observable.<Integer>fromCallable(() -> {
Thread.sleep(1000);
return 1;
})
.timeout(800, TimeUnit.MILLISECONDS)
.subscribeOn(Schedulers.io())
.onErrorReturn(throwable -> {
System.out.printf("Server did not respond within %s ms for id=%s%n", 800, 1);
return 2;
})