more useful options | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Hi BioHazard,
From what I understand from the snippet, your script takes a "node" (xml file), renders html based on its content and recursively calls itself for every "child" element encountered (the child element references another xml file). At the end, your sub returns a flattened HTML string (if I interpret HTML::Template's output() method correctly). Both the XML::Simple object and HTML::Template object go out of scope. That means, that during the recursive process the max. amount of memory depende on the total length of the outputted HTML string, together with (the recursion depth) x ((the memory needed for a XML::Simple instance) + (a HTML::Template instance)). From your example XML snippet, this looks not like a big deal. I'm not familiar with XML::Simple's internals, but being based on a SAX parser (expat) I guess that after parsing mostly the Hash of Hashes/Lists of the $node object remains. Whether this implementation is too slow depends largely on the nesting depth and your definition of "slow", but in order to save on both memory and CPU, you could conceivably render these discussion threads to static files in a background process, on regular intervals or as soon as a new item has been added to the discussion. Or even on first request, from a nifty 404 error handler ;-) Just my $0.02 -- In reply to Re: Node Parser too slow?
by joe++
|
|