-
-
Save juliangruber/4cb477c109fee5b60cb77686442e85b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/juliangruber/async-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('async', () => async () => {}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ node stream-heap.js | |
Readable 514.95448 130 | |
Writable 179.23304 247 | |
Transform 560.3488 471 | |
$ node pull-heap.js | |
values 155.53112 44 | |
map 84.62736 9 | |
drain 221.48776 93 | |
$ node push-heap.js | |
Values 63.6348 31 | |
Map 103.9844 45 | |
Collect 112.44888 10 | |
$ node async-heap.js | |
async 87.18784 40 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment