I've got a chunk of code that can operate one of two ways:

Snippet of the code (%contacts has values of a XML::LibXML::Node for each contact).

# other code to retrieve the documents into %contacts foreach my $id ( keys %$contacts ) { my $entry = $contacts->{$id}; my $xml = $entry->toStringC14N(); }

Retrieve a large number of small XML documents (with say 100 nodes each) - this is slow, as it has lots of separate web requests to retrieve the content

or

Retrieve a small number of large XML documents (with say 10k-25k nodes each) - this is fast, can retrieve almost all of the content in one or two requests.

Only difference between the two loops is that the nodes in %contacts are either from 1-2 XML::LibXML::Document's, or are from 100+ documents.) Both end up with the same total set of data.

Problem is, when I use the 'large xml document' approach, each toStringC14N() call on is very slow. (1-2/sec)

If I use the small chunk approach, retrieving the data takes a lot longer, but the processing of the nodes runs in the 100-200/sec range or higher.

Is there anything I can do to speed things up when using the large document retrieval, or do I have to just pick a balance between the two extremes?


In reply to How to speed up XML::LibXML toStringC14N - when used on large document? by nneul

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.