Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Anonymous function allocation benchmark
//usage
// node test.js --nouse-idle-notification -test1
// node test.js --nouse-idle-notification -test2
// then compare memory usage
var a = [];
function Test1()
{
return function()
{
a.push({a: 'b'});
}
}
function Test2()
{
a.push({a: 'b'});
}
var c = 1000000;
var arguments = process.argv.splice(2);
if(arguments.indexOf('-test1') > 0)
{
while(c--)
Test1()();
}
if(arguments.indexOf('-test2') > 0)
{
while(c--)
Test2();
}
console.log(process.memoryUsage());
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.