-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperf.js
36 lines (31 loc) · 996 Bytes
/
perf.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import Bench from 'benchmark'
import bluebird from 'bluebird'
import pMap from 'p-map'
import promisu from 'promisu'
import { conch } from '../dist/index.mjs'
const suite = new Bench.Suite()
const data = Array.from(Array(10).keys())
const mapper = async item => {
return item * 2
}
suite
.add('conch', function () {
conch(data, mapper, { limit: data.length / 2 }).then(() => {})
})
.add('p-map', function () {
pMap(data, mapper, { concurrency: data.length / 2 }).then(() => {})
})
.add('promisu', function () {
promisu
.PromisuMap(data, mapper, { concurrency: data.length / 2 })
.then(() => {})
})
// .add('bluebird', function () {
// bluebird.map(data, mapper, { concurrency: data.length / 2 })
// })
.on('cycle', e => console.log(' ' + e.target))
.on('complete', function () {
console.log('Fastest :' + this.filter('fastest').map('name'))
console.log('Slowest :' + this.filter('slowest').map('name'))
})
.run({ async: true })