git ssb

2+

Dominic / pull-stream



Tree: 2b8ed0b778ffe06dbf19898b0cdeb8e009224087

Files: 2b8ed0b778ffe06dbf19898b0cdeb8e009224087 / benchmarks / pull.js

1307 bytesRaw
1const bench = require('fastbench')
2const pull = require('../')
3
4const values = [
5 JSON.stringify({ hello: 'world' }),
6 JSON.stringify({ foo: 'bar' }),
7 JSON.stringify({ bin: 'baz' })
8]
9
10const run = bench([
11 function pull3 (done) {
12 const source = pull.values(values)
13 const through = pull.asyncMap(function (val, done) {
14 const json = JSON.parse(val)
15 done(null, json)
16 })
17
18 const sink = pull.collect(function (err, array) {
19 if (err) return console.error(err)
20 setImmediate(done)
21 })
22 pull(source, through, sink)
23 },
24 function pull_compose (done) {
25 const source = pull.values(values)
26 const through = pull.asyncMap(function (val, done) {
27 const json = JSON.parse(val)
28 done(null, json)
29 })
30
31 const sink = pull.collect(function (err, array) {
32 if (err) return console.error(err)
33 setImmediate(done)
34 })
35 pull(source, pull(through, sink))
36 },
37 function pull_chain (done) {
38 const source = pull.values(values)
39 const through = pull.asyncMap(function (val, done) {
40 const json = JSON.parse(val)
41 done(null, json)
42 })
43
44 const sink = pull.collect(function (err, array) {
45 if (err) return console.error(err)
46 setImmediate(done)
47 })
48 pull(pull(source, through), sink)
49 }
50], 100000)
51
52run()
53
54

Built with git-ssb-web