|XP is just a number|
perlcritic speedupby powerman (Friar)
|on Jan 24, 2012 at 14:05 UTC||Need Help??|
powerman has asked for the
wisdom of the Perl Monks concerning the following question:
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?