Skip to content

Instantly share code, notes, and snippets.

@polotek
Created December 30, 2010 19:18
Show Gist options
  • Save polotek/760165 to your computer and use it in GitHub Desktop.
Save polotek/760165 to your computer and use it in GitHub Desktop.
var sys = require('sys');
var _ = require('underscore')._;
var XML = require('libxmljs');
var mem = require('myutils').loadmem(XML);
process.addListener('exit', function () {
sys.debug('exiting');
mem();
});
var i = 0,
filename = 'data/AWSECommerceService.wsdl',
iters = 100,
wait = 5000;
function looptest() {
for(; i<iters; i++) {
mem();
doc = XML.parseXmlFile(filename);js
doc.root().attr({'fizz': 'buzz'});
//delete doc;
gc();
}
sys.debug('Time: ' + ((new Date) - d));
delete doc;
if(wait) {
sys.debug('waiting for ' + wait/1000 + ' seconds');
setTimeout(function() {
gc();
mem();
}, wait);
}
}
function eventlooptest() {
gc();
mem();
doc = XML.parseXmlFile(filename);
doc.root().attr({'fizz': 'buzz'});
i++;
if(i<iters) {
process.nextTick(arguments.callee);
} else {
sys.debug('Time: ' + ((new Date) - d));
delete doc;
sys.debug('wait: ' + wait);
if(wait) {
sys.debug('waiting for ' + wait/1000 + ' seconds');
setTimeout(function() {
gc();
mem();
}, wait);
}
}
}
var d = new Date();
//looptest();
eventlooptest();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment