diff --git a/benchmarks.md b/benchmarks.md index 2137c25..17c149d 100644 --- a/benchmarks.md +++ b/benchmarks.md @@ -4,20 +4,22 @@ ┌─────────────────────────────────────────────────────┬────────────────┬─────────┐ │ name │ ops/sec │ samples │ ├─────────────────────────────────────────────────────┼────────────────┼─────────┤ -│ create │ 393 (±70.95%) │ 56 │ +│ create │ 641 (±14.07%) │ 45 │ ├─────────────────────────────────────────────────────┼────────────────┼─────────┤ -│ file -> debounce │ 925 (±6.47%) │ 51 │ +│ file -> debounce │ 804 (±9.85%) │ 46 │ ├─────────────────────────────────────────────────────┼────────────────┼─────────┤ -│ file -> combine(sum3, [a, b, c]) -> reduce(sum2, 0) │ 85,217 (±4.7%) │ 61 │ +│ file -> combine(sum3, [a, b, c]) -> reduce(sum2, 0) │ 88,588 (±3.7%) │ 69 │ ├─────────────────────────────────────────────────────┼────────────────┼─────────┤ -│ file -> map -> reduce │ 57 (±1.09%) │ 68 │ +│ file -> map -> reduce │ 56 (±1.18%) │ 66 │ ├─────────────────────────────────────────────────────┼────────────────┼─────────┤ -│ file -> scan -> reduce │ 29 (±3.08%) │ 69 │ +│ file -> scan -> reduce │ 30 (±1.17%) │ 70 │ ├─────────────────────────────────────────────────────┼────────────────┼─────────┤ -│ file -> takeN(0, n/10) │ 461 (±1.75%) │ 77 │ +│ file -> takeN(0, n/10) │ 465 (±1.05%) │ 77 │ ├─────────────────────────────────────────────────────┼────────────────┼─────────┤ -│ array(2) -> array(i) -> switchLatest │ 5,158 (±4.41%) │ 67 │ +│ file -> mergeMap │ 479 (±2.44%) │ 76 │ ├─────────────────────────────────────────────────────┼────────────────┼─────────┤ -│ tryCatch │ 2,527 (±1.12%) │ 88 │ +│ array(2) -> array(i) -> switchLatest │ 4,946 (±4.48%) │ 70 │ +├─────────────────────────────────────────────────────┼────────────────┼─────────┤ +│ tryCatch │ 2,445 (±1.13%) │ 84 │ └─────────────────────────────────────────────────────┴────────────────┴─────────┘ ``` diff --git a/benchmarks/bm.mergeMap.ts b/benchmarks/bm.mergeMap.ts new file mode 100644 index 0000000..6aba6d2 --- /dev/null +++ b/benchmarks/bm.mergeMap.ts @@ -0,0 +1,18 @@ +/** + * Created by tushar on 31/08/17. + */ + +import {Suite} from 'benchmark' +import {mergeMap} from '../src/operators/MergeMap' +import {fromArray} from '../src/sources/FromArray' +import {array, IDeferred, run} from './lib' + +const a = array(1e3).map(i => array(1e3)) + +export function bm_mergeMap(suite: Suite) { + return suite.add( + 'file -> mergeMap', + (d: IDeferred) => run(mergeMap(1e2, fromArray, fromArray(a)), d), + {defer: true} + ) +} diff --git a/benchmarks/run.ts b/benchmarks/run.ts index a7647b4..91a7435 100644 --- a/benchmarks/run.ts +++ b/benchmarks/run.ts @@ -8,6 +8,7 @@ import {bm_debounce} from './bm.debounce' import {bm_fromArray_map_reduce} from './bm.fromArray-map-reduce' import {bm_fromArray_scan_reduce} from './bm.fromArray-scan-reduce' import {bm_fromArray_takeN} from './bm.fromArray-takeN' +import {bm_mergeMap} from './bm.mergeMap' import {bm_switch} from './bm.switch' import {bm_tryCatch} from './bm.tryCatch' import {onCycle, onEnd} from './lib' @@ -26,4 +27,5 @@ bm_fromArray_scan_reduce(suite) bm_fromArray_takeN(suite) bm_switch(suite) bm_tryCatch(suite) +bm_mergeMap(suite) suite.on('cycle', onCycle).on('complete', onEnd).run()