Netflix/RxJava — pull request #1366 by benjchristensen (2014-06-16 23:51:33+00:00)
Title: Backpressure-5: Merge, ObserveOn, SubscribeOn, etc

- Mostly functional backpressure with `merge` and `observeOn`.
- Pivot and Parallel operators have issues and unit tests and ignored.
- This is NOT production ready. Need to work on algorithms in merge, data structures and concurrency implementations.

Performance of `flatMap` compared with 0.19:

```
../gradlew benchmarks '-Pjmh=-f 1 -tu s -bm thrpt -wi 5 -i 5 -r 2 -prof GC rx.usecases.PerfObserveOn.observeOnComputation'
```

Current

```
Benchmark (size) Mode Samples Mean Mean error Units
r.u.PerfTransforms.flatMapInt 1 thrpt 5 1513055.461 35120.889 ops/s
r.u.PerfTransforms.flatMapInt 1024 thrpt 5 2229.818 50.863 ops/s
r.u.PerfTransforms.flatMapNestedMapFilterTake 1 thrpt 5 1114912.405 137096.910 ops/s
r.u.PerfTransforms.flatMapNestedMapFilterTake 1024 thrpt 5 82.799 1.695 ops/s
```

0.19 master

```
Benchmark (size) Mode Samples Mean Mean error Units
r.u.PerfTransforms.flatMapInt 1 thrpt 5 3372557.564 131729.592 ops/s
r.u.PerfTransforms.flatMapInt 1024 thrpt 5 6713.975 159.005 ops/s
r.u.PerfTransforms.flatMapNestedMapFilterTake 1 thrpt 5 2231392.499 50190.297 ops/s
r.u.PerfTransforms.flatMapNestedMapFilterTake 1024 thrpt 5 16.437 0.413 ops/s
```

```java
input.observable.flatMap(i -> {
return Observable.from(i);
}).subscribe(input.observer);
```

Current

```
Run: 10 - 1,697,014 ops/sec
Run: 11 - 1,675,210 ops/sec
Run: 12 - 1,781,483 ops/sec
Run: 13 - 1,674,677 ops/sec
Run: 14 - 1,714,354 ops/sec
```

vs 0.19

```
Run: 10 - 2,809,225 ops/sec
Run: 11 - 3,051,850 ops/sec
Run: 12 - 3,100,006 ops/sec
Run: 13 - 3,007,699 ops/sec
Run: 14 - 3,114,585 ops/sec
```