Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSR12/OpenTag: improve performance #3840

Closed
wants to merge 1 commit into from

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Jun 4, 2023

Description

No functional changes at all, just improving performance of the sniff by changing the order of certain checks.

Some benchmarks for this change run using the Performance report (PR #3810):

Command: phpcs -ps . --extensions=php --ignore=/vendor/ --report=performance --standard=psr12

Output for the PSR12.Files.OpenTag sniff:

Result PHPCS itself Set of Projects A Set of Projects B Set of Projects C
Nr of Files Scanned 614 4115 25546 2250
Before 0.077045 ( 2.3 %) 0.982014 ( 1.9 %) 3.267655 ( 2.1 %) 0.179564 ( 2.1 %)
After 0.000928 ( 0.0 %) 0.013066 ( 0.0 %) 0.091816 ( 0.1 %) 0.109021 ( 1.3 %)

With what the sniff does, the impact is biggest for files/codebases which already comply with the expectations of this sniff.

Suggested changelog entry

PSR12.Files.OpenTag: improved time-to-result for the sniff

Related issues/external references

Fixes #

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
    • This change is only breaking for integrators, not for external standards or end-users.
  • Documentation improvement

No functional changes at all, just improving performance of the sniff by changing the order of certain checks.

Some benchmarks for this change run using the Performance report (PR 3810):

Command: `phpcs -ps . --extensions=php --ignore=/vendor/ --report=performance --standard=psr12`

Output for the `PSR12.Files.OpenTag` sniff:

Result | PHPCS itself       | Set of Projects A  | Set of Projects B  | Set of Projects C |
------ | ------------------ | ------------------ | ------------------ | ----------------- |
Nr of Files Scanned | 614   | 4115               | 25546              | 2250              |
Before | 0.077045 (  2.3 %) | 0.982014 (  1.9 %) | 3.267655 (  2.1 %) | 0.179564 (  2.1 %)
After  | 0.000928 (  0.0 %) | 0.013066 (  0.0 %) | 0.091816 (  0.1 %) | 0.109021 (  1.3 %)

With what the sniff does, the impact is biggest for files/codebases which already comply with the expectations of this sniff.
@jrfnl
Copy link
Contributor Author

jrfnl commented Dec 2, 2023

Closing as replaced by PHPCSStandards/PHP_CodeSniffer#64

@jrfnl jrfnl closed this Dec 2, 2023
@jrfnl jrfnl deleted the feature/psr12-opentag-improve-performance branch December 2, 2023 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant