Skip to content

Commit

Permalink
chore(mergeMap): add benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharmath committed Sep 1, 2017
1 parent 0aafe65 commit 794c416
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
18 changes: 10 additions & 8 deletions benchmarks.md
Expand Up @@ -4,20 +4,22 @@
┌─────────────────────────────────────────────────────┬────────────────┬─────────┐
│ name │ ops/sec │ samples │
├─────────────────────────────────────────────────────┼────────────────┼─────────┤
│ create │ 39370.95%) │ 56
│ create │ 64114.07%) │ 45
├─────────────────────────────────────────────────────┼────────────────┼─────────┤
│ file -> debounce │ 9256.47%) │ 51
│ file -> debounce │ 8049.85%) │ 46
├─────────────────────────────────────────────────────┼────────────────┼─────────┤
│ file -> combine(sum3, [a, b, c]) -> reduce(sum2, 0) │ 85,2174.7%) │ 61
│ file -> combine(sum3, [a, b, c]) -> reduce(sum2, 0) │ 88,5883.7%) │ 69
├─────────────────────────────────────────────────────┼────────────────┼─────────┤
│ file -> map -> reduce │ 57 (±1.09%) │ 68
│ file -> map -> reduce │ 56 (±1.18%) │ 66
├─────────────────────────────────────────────────────┼────────────────┼─────────┤
│ file -> scan -> reduce │ 293.08%) │ 69
│ file -> scan -> reduce │ 301.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,1584.41%) │ 67
file -> mergeMap │ 4792.44%) │ 76
├─────────────────────────────────────────────────────┼────────────────┼─────────┤
│ tryCatch │ 2,527 (±1.12%) │ 88 │
│ array(2) -> array(i) -> switchLatest │ 4,946 (±4.48%) │ 70 │
├─────────────────────────────────────────────────────┼────────────────┼─────────┤
│ tryCatch │ 2,445 (±1.13%) │ 84 │
└─────────────────────────────────────────────────────┴────────────────┴─────────┘
```
18 changes: 18 additions & 0 deletions 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}
)
}
2 changes: 2 additions & 0 deletions benchmarks/run.ts
Expand Up @@ -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'
Expand All @@ -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()

0 comments on commit 794c416

Please sign in to comment.