Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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