I'd like to run perlcritic just like any other lint tool - each time I save file in Vim. But, truth is, perlcritic is too SLOW. It took about 1.5 seconds to check small file, and such delay on 'save file' operation isn't acceptable.

I've tried to use B::Bytecode compiler, including as much as possible modules used by perlcritic (381 modules, size of compiled file with bytecode ~240KB), but this doesn't make it faster at all.

I've also experimented with Devel::DProf, but at a glance there is no obvious bottlenecks, with a lot of luck there is a chance to quickly speedup it in 10-20% at most, which is surely not enough.

Last (actually, first) idea is to run perlcritic as client-server. This should save about 0.5-0.7 second, but ~0.8-1 second for checking file is still too slow.

I'm also think about limiting amount of tests executed by perlcritic by running it with -5 option while there are any errors found, and then run it with -4, -3, etc. This will speedup check when there are errors, but in case there is no errors (which is much more often) it actually will be slower because with -3 it will repeat already-done checks for -4 and -5. Also it have similar -top option, but using it actually make things slower.

With all these optimizations there is a chance to make it run in ~0.5 sec in _best_ case, which is probably more or less acceptable, but I'm afraid usually it won't be best case and it will take much longer to run.

So… any ideas how to speedup perlcritic to 0.3sec or less on average input?


In reply to perlcritic speedup by powerman

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.