Skip to content

Instantly share code, notes, and snippets.

@eendeego
Created February 23, 2013 18:06
Show Gist options
  • Save eendeego/5020702 to your computer and use it in GitHub Desktop.
Save eendeego/5020702 to your computer and use it in GitHub Desktop.
#!/usr/bin/env node --trace_gc
# See also "Timers" in
# http://coding.smashingmagazine.com/2012/11/05/writing-fast-memory-efficient-javascript/
'use strict';
process.on('uncaughtException', function (err) {
console.log('Caught exception: ' + err);
});
var counter = 0;
var wat = 0;
function incCounter(i) {
wat += i;
return ++counter;
}
for (var j=0; j < 10000; j++) {
for (var i=0; i < 10000; i++) {
var func = "function x_" + i + " () { return incCounter(" + i + "); };x_" + i + "();";
eval(func);
}
console.log('Counter value: %s', counter);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment