Created
April 10, 2010 08:05
-
-
Save polotek/361906 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 sys = require('sys'); | |
var XML = require('libxmljs'); | |
var doc = null; | |
function mem() { | |
sys.debug(sys.inspect(process.memoryUsage()).replace(/\n/g, '')); | |
sys.debug(sys.inspect(XML.memoryUsage())); | |
} | |
var i = 0, | |
filename = 'aol_com.html', | |
iters = 50, | |
wait = 5000; | |
function looptest() { | |
for(; i<iters; i++) { | |
sys.debug(i); | |
doc = XML.parseHtmlFile(filename); | |
sys.puts(doc); | |
var body = doc.get('//body'); | |
sys.puts(body); | |
mem(); | |
} | |
// delete doc, body; | |
if(wait) { | |
sys.debug('waiting for ' + wait/1000 + ' seconds'); | |
setTimeout(mem, wait); | |
} | |
} | |
function eventlooptest() { | |
sys.debug(i); | |
doc = XML.parseHtmlFile(filename); | |
sys.puts(doc); | |
var body = doc.get('//body'); | |
sys.puts(body.toString()); | |
mem(); | |
i++; | |
if(i<iters) { | |
process.nextTick(arguments.callee); | |
//setTimeout(arguments.callee, 100); | |
} else { | |
delete doc, body; | |
if(wait) { | |
sys.debug('waiting for ' + wait/1000 + ' seconds'); | |
setTimeout(mem, wait); | |
} | |
} | |
} | |
//looptest(); | |
eventlooptest(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment