Skip to content

UtilityMethodTestCase: performance improvement - #525

Merged
jrfnl merged 1 commit into
developfrom
feature/utilitymethodtestcase-improve-performance
Dec 7, 2023
Merged

jrfnl merged 1 commit into
developfrom
feature/utilitymethodtestcase-improve-performance

Conversation

@jrfnl

@jrfnl jrfnl commented Dec 7, 2023

Copy link
Copy Markdown
Member

PR squizlabs/PHP_CodeSniffer#3831 / PHPCSStandards/PHP_CodeSniffer#61 in PHPCS itself makes a change to improve the performance of the Config class.

This commit lets the UtilityMethodTestCase take advantage of that performance improvement by explicitly passing the report_width to prevent a call to shell_exec('stty ...') from being made and slowing down the tests.

While not benchmarked properly, with the test runs for PHPCSUtils on my local machine on Windows, the difference this change makes is significant and noticable:

  • Before: 2.5 minutes.
  • After: 1 second.

This advantage can only be seen with PHPCS 3.8.0 or higher, but the change does not negatively impact test runs against PHPCS < 3.8.0, so there is no need to raise the minimum PHPCS version.

PR squizlabs/PHP_CodeSniffer 3831 / PHPCSStandards/PHP_CodeSniffer 61 in PHPCS itself makes a change to improve the performance of the `Config` class.

This commit lets the `UtilityMethodTestCase` take advantage of that performance improvement by explicitly passing the `report_width` to prevent a call to `shell_exec('stty ...')` from being made and slowing down the tests.

While not benchmarked properly, with the test runs for PHPCSUtils on my local machine on Windows, the difference this change makes is significant and noticable:
* Before: **2.5 minutes**.
* After: **1 second**.

This advantage can only be seen with PHPCS 3.8.0 or higher, but the change does not negatively impact test runs against PHPCS < 3.8.0, so there is no need to raise the minimum PHPCS version.
@jrfnl jrfnl added this to the 1.0.9 milestone Dec 7, 2023
@jrfnl
jrfnl marked this pull request as ready for review December 7, 2023 02:01
@jrfnl
jrfnl merged commit dc93c9a into develop Dec 7, 2023
@jrfnl
jrfnl deleted the feature/utilitymethodtestcase-improve-performance branch December 7, 2023 02:05
jrfnl added a commit to PHPCSStandards/PHPCSDevTools that referenced this pull request Mar 4, 2024
PHPCSUtils 1.0.9 made a change to the `UtilityMethodTestCase` which causes the selected sniff to no longer register its token listeners as the `installed_paths` from the `CodeSniffer.conf` file are no longer read out.

While this is fine for actual utility methods, it breaks the tests for the `PHPCSDebug.Debug.TokenList` test.

Fixed now.

Refs:
* https://github.com/PHPCSStandards/PHPCSUtils/releases/tag/1.0.9
* PHPCSStandards/PHPCSUtils#525
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant