webimpress / coding-standard

Webimpress Coding Standard for PHP_CodeSniffer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Performance problems with internal PHP sniffs

FabianKoestring opened this issue · comments

Hey there,

on some files we have performance problems with both sniffs (src/WebimpressCodingStandard/Sniffs/PHP/ImportInternalConstantSniff.php and src/WebimpressCodingStandard/Sniffs/PHP/ImportInternalFunctionSniff.php).

Sometimes these sniffs will take up to 20 seconds.

Do you need more data or could this behavior be normal?

@FabianKoestring

it could be normal for big files - I mean this is what I observed in the past - big file, many internal functions used....

Probably still it is possible to improve the code, so more data could be useful :) Thanks!

@FabianKoestring

it could be normal for big files - I mean this is what I observed in the past - big file, many internal functions used....

Probably still it is possible to improve the code, so more data could be useful :) Thanks!

I could provide more information. What do you need?

@FabianKoestring Example file would be the best. If you can share a file for which the operation is very slow I would be able to xdebug it, check what part is actually slow and try to make it better.

Hey @michalbundyra sry for my late reply. I dont want make my private code public so i searched for slow files in some of my vendors. It seems like https://github.com/doctrine/dbal/blob/2.10.x/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php is a relativly big and slow file.

@FabianKoestring Sorry for late response... I had a quick look on it.
I can confirm, it's fairly slow for big files, but I check also other rules, and it's general issue for big files.
These sniff is even slower as it process all strings in the file, need to recognise namespace, etc.. There is a lot going on.

I cannot see right now any simple fix to improve performance here, and as it is affecting just big files, I am not going to spend more time on it now. Probably from maintenance point of view it would be better to split big files into smaller, if possible.

I am leaving this ticket as open and adding label "help wanted" as maybe someone will be able to investigate it more and provide some improvements.

Thanks for reporting and providing example file.