Created
May 17, 2011 17:30
-
-
Save tmpvar/976918 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
var | |
Context = process.binding('evals').Context, | |
Script = process.binding('evals').Script, | |
total = 10000, | |
result = null; | |
process.nextTick(function memory() { | |
var mem = process.memoryUsage(); | |
console.log('rss:', Math.round(((mem.rss/1024)/1024)) + "MB"); | |
setTimeout(memory, 100); | |
}); | |
console.log("STARTING"); | |
process.nextTick(function run() { | |
var context = new Context(), timers = { | |
interval : [], | |
timeout : [] | |
}; | |
context.setInterval = function(fn, timeout) { | |
timers.interval.push(setInterval(fn, timeout)); | |
}, | |
context.setTimeout = function(fn, timeout) { | |
timers.timeout.push(setTimeout(fn, timeout)); | |
}; | |
Script.runInContext('setInterval(function() {}, 0);', | |
context, 'test.js'); | |
process.nextTick(function() { | |
var intervalLength = timers.interval.length, | |
timeoutLength = timers.timeout.length; | |
while (intervalLength--) { | |
clearInterval(timers.interval[intervalLength]); | |
} | |
while (timeoutLength--) { | |
clearTimeout(timers.timeout[timeoutLength]); | |
} | |
context.stop(); | |
}); | |
total--; | |
if (total) { | |
process.nextTick(run); | |
} else { | |
console.log("COMPLETE"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment