It might help to post your timing results along with the code. Systems differ and it is possible that the timing results you see are specific to your system rather than something internal to the Perl interpreter.

On my system, the time it takes to parse each line is essentially 0 - so I'm not sure what you are concerned about.

1234974983.91134 1234974983.91134 1234974983.91134 1234974983.92134

If you aren't getting the same results, I suspect the problem is your print lines. They take a *huge* amount of time relative to the regex parser. If I run Extract 1000 times and compare the time before the first run and after the 1000th run, I get 0.22 seconds with only the line: "Extract begins with..." printing out and 0.03 seconds if I remove all prints from within the loop

The bottom line: don't use print statements to profile code - you'll be measuring the print statements, not the code performance. A better option is to use the -d:DProf option, e.g. perl -d:DProf myscript.pl - see Profiling Perl and module documentation Devel::DProf.

Best, beth


In reply to Re: Performance issue by ELISHEVA
in thread Performance issue by balakrishnan

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.