squizlabs / PHP_CodeSniffer

PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.
BSD 3-Clause "New" or "Revised" License
10.63k stars 1.48k forks source link

Caching on Windows makes CS check incredibly slow #3558

Closed jrfnl closed 7 months ago

jrfnl commented 2 years ago

Describe the bug

I've done some - not entirely scientific - benchmark checks and am finding that enabling the caching option when on Windows (not sure about other OSes), makes a CS run significantly slower.

For a CS run with a custom ruleset and the following command over 57 files:

phpcs ./inc/ --sniffs=Squiz.Commenting.FunctionComment,Universal.Operators.StrictComparisons,Generic.CodeAnalysis.EmptyPHPStatement,PHPCompatibility.ParameterValues.NewHTMLEntitiesFlagsDefault,PSR12.Files.FileHeader,Squiz.Commenting.InlineComment,WordPress.WP.PostsPerPage

These are the approximate timings I'm seeing:

Checked against Time with cache ON Time without cache OFF (--no-cache)
master Time: 3 mins, 5.61 secs; Memory: 78MB Time: 3.7 secs; Memory: 36MB

Expected behavior I would expect a little bit of a slow-down the first time PHPCS is run with cache turned on as the cache file needs to be written, but the slow-down I'm seeing now is out of bounds.

Versions (please complete the following information):

Additional context I haven't done a git bisect yet to figure out if I can pinpoint the slow-down to a specific commit, but felt that the time difference is so huge and on the negative for having caching turned on, this had to be reported forthwith.

jrfnl commented 7 months ago

Closing as replaced by PHPCSStandards/PHP_CodeSniffer#26