Hello fellow monks, I encountered some strange benchmark results when I was testing the performance of my current project. At some point in the code the following simple lines can be found.
$tree -> parse_file ($file); # $tree is a XML::TreeBuilder my @results = $tree -> look_down ('attr' => 'value');
Now, watch. First line:
timethis (5000, sub {$tree -> parse_file ($file)}); timethis 5000: 16 wallclock secs (12.98 usr + 1.41 sys = 14.39 CPU) @ + 347.46/s (n=5000)
Second line:
timethis (5000, sub {my @results = $tree -> look_down('attr' => 'value +')}); timethis 5000: 2 wallclock secs ( 1.42 usr + 0.00 sys = 1.42 CPU) @ + 3516.17/s (n=5000)
First and second line:
timethis (500, sub {$tree -> parse_file ($file); my @results = $tree - +> look_down('attr'=> 'value')}); timethis 500: 36 wallclock secs (34.32 usr + 0.19 sys = 34.51 CPU) @ +14.49/s (n=500)
Shouldn't the total speed be something over 300? Am I missing something fundamental? Any ideas?

In reply to XML::TreeBuilder strange benchmarking behaviour by Mandor

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.