Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$ node stream-heap.js
Readable 358.53592 134
Writable 623.37824 258
Transform 709.05584 1310
$ node pull-heap.js
values 155.2692 70
map 84.50328 7
drain 203.86776 73
$ node push-heap.js
Values 63.6348 31
Map 103.9844 45
Collect 112.44888 10
var pull = require('pull-stream')
function heap (name, Stream) {
var start = Date.now()
var heap = process.memoryUsage().heapUsed
var a = [], N = 100000
for(var i = 0; i < N; i++)
a.push(Stream())
console.log(name, (process.memoryUsage().heapUsed - heap)/N, (Date.now()-start))
a = null
}
heap('values', pull.values)
heap('map', pull.map)
heap('drain', pull.drain)
function heap (name, Stream) {
var start = Date.now()
var heap = process.memoryUsage().heapUsed
var a = [], N = 100000
for(var i = 0; i < N; i++)
a.push(new Stream())
console.log(name, (process.memoryUsage().heapUsed - heap)/N, (Date.now()-start))
a = null
}
heap('Values', require('push-stream--/values'))
heap('Map', require('push-stream--/async'))
heap('Collect', require('push-stream--/collect'))
var streams = require('stream')
function heap (name, Stream) {
var start = Date.now()
var heap = process.memoryUsage().heapUsed
var a = [], N = 100000
for(var i = 0; i < N; i++)
a.push(new Stream())
console.log(name, (process.memoryUsage().heapUsed - heap)/N, (Date.now()-start))
a = null
}
heap('Readable', streams.Readable)
heap('Writable', streams.Writable)
heap('Transform', streams.Transform)
@dominictarr

This comment has been minimized.

Copy link
Owner Author

dominictarr commented Jan 4, 2018

!!! creating 100k empty transform streams takes over a second !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.