You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.4 KiB

const bench = require('fastbench')
const pull = require('../')
const values = [
JSON.stringify({ hello: 'world' }),
JSON.stringify({ foo: 'bar' }),
JSON.stringify({ bin: 'baz' })
]
const run = bench([
function pull3 (done) {
const source = pull.values(values)
const through = pull.asyncMap(function (val, done) {
const json = JSON.parse(val)
done(null, json)
})
const sink = pull.collect(function (err, array) {
if (err) return console.error(err)
setImmediate(done)
})
pull(source, through, sink)
}/*,
function pull_compose (done) {
const source = pull.values(values)
const through = pull.asyncMap(function (val, done) {
const json = JSON.parse(val)
done(null, json)
})
const sink = pull.collect(function (err, array) {
if (err) return console.error(err)
setImmediate(done)
})
pull(source, pull(through, sink))
},
function pull_chain (done) {
const source = pull.values(values)
const through = pull.asyncMap(function (val, done) {
const json = JSON.parse(val)
done(null, json)
})
const sink = pull.collect(function (err, array) {
if (err) return console.error(err)
setImmediate(done)
})
pull(pull(source, through), sink)
}*/
], N=100000)
var heap = process.memoryUsage().heapUsed
run(function () {
console.log((process.memoryUsage().heapUsed - heap)/N)
})