Created
February 19, 2018 13:56
-
-
Save mcheshkov/8f32de938123a64d856c3146a3261255 to your computer and use it in GitHub Desktop.
This file contains 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
const TOPIC_BUFFER = 'topic'; | |
const MSG_LEN = 7; | |
function topic() { | |
return 'topic'; | |
return TOPIC_BUFFER.toString(); | |
} | |
const SINGLE_BUFFER = Buffer.alloc(MSG_LEN); | |
function msg() { | |
return SINGLE_BUFFER; | |
return Buffer.alloc(MSG_LEN); | |
} | |
function createArray() { | |
return [topic(), msg()]; | |
} | |
function createObject() { | |
return {topic: topic(), msg:msg()}; | |
} | |
const count = 1e6; | |
const result = []; | |
const before = process.memoryUsage(); | |
console.log("BEFORE", before); | |
for (let i = 0; i< count; ++i) { | |
result.push(createArray()); | |
// result.push(createObject()); | |
} | |
const after = process.memoryUsage(); | |
console.log("AFTER", after); | |
console.log("DELTA"); | |
console.log("RSS", after.rss - before.rss); | |
console.log("Used heap", after.heapUsed - before.heapUsed); | |
console.log(result.length); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment