Skip to content

Instantly share code, notes, and snippets.

@mcheshkov
Created February 19, 2018 13:56
Show Gist options
  • Save mcheshkov/8f32de938123a64d856c3146a3261255 to your computer and use it in GitHub Desktop.
Save mcheshkov/8f32de938123a64d856c3146a3261255 to your computer and use it in GitHub Desktop.
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