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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: cache jest fn call parsing results #1187

Merged
merged 2 commits into from Aug 15, 2022
Merged

perf: cache jest fn call parsing results #1187

merged 2 commits into from Aug 15, 2022

Conversation

G-Rath
Copy link
Collaborator

@G-Rath G-Rath commented Aug 7, 2022

This adds caching to greatly reduce the cost of parseJestFnCall - currently most rules now sit around the 300-700ms mark, and this takes them down to about ~30ms (after the initial hit).

Running with all against the jest codebase:

TIMING=1 npx eslint --no-eslintrc --config my-eslint-config.cjs . --ext js,ts,tsx,jsx

before:

Rule                          | Time (ms) | Relative
:-----------------------------|----------:|--------:
jest/consistent-test-it       |   959.762 |     4.5%
jest/no-standalone-expect     |   866.172 |     4.0%
jest/prefer-expect-assertions |   854.663 |     4.0%
jest/no-conditional-expect    |   798.178 |     3.7%
jest/no-conditional-in-test   |   770.365 |     3.6%
jest/no-duplicate-hooks       |   767.634 |     3.6%
jest/no-identical-title       |   760.904 |     3.5%
jest/no-disabled-tests        |   751.041 |     3.5%
jest/prefer-snapshot-hint     |   749.891 |     3.5%
jest/prefer-hooks-in-order    |   747.734 |     3.5%

after:

Rule                          | Time (ms) | Relative
:-----------------------------|----------:|--------:
jest/consistent-test-it       |   189.048 |    23.6%
jest/expect-expect            |    53.102 |     6.6%
jest/require-hook             |    50.167 |     6.3%
jest/prefer-expect-assertions |    46.285 |     5.8%
jest/no-standalone-expect     |    32.031 |     4.0%
jest/unbound-method           |    28.302 |     3.5%
jest/no-deprecated-functions  |    25.051 |     3.1%
jest/valid-title              |    24.635 |     3.1%
jest/no-conditional-expect    |    21.598 |     2.7%
jest/no-jasmine-globals       |    16.126 |     2.0%

(@SimenB we should make sure that pref actually triggers a release before merging this 馃槄)

@G-Rath G-Rath requested a review from SimenB August 7, 2022 20:11
@SimenB
Copy link
Member

SimenB commented Aug 7, 2022

(@SimenB we should make sure that pref actually triggers a release before merging this 馃槄)

It should trigger a patch release, looking at https://github.com/semantic-release/commit-analyzer/blob/ad3079b515be8266da02cc6dc64f765dd8aaf509/lib/default-release-rules.js#L12

src/rules/utils/parseJestFnCall.ts Outdated Show resolved Hide resolved
@SimenB SimenB merged commit 525631e into main Aug 15, 2022
@SimenB SimenB deleted the add-parse-caching branch August 15, 2022 08:48
github-actions bot pushed a commit that referenced this pull request Aug 15, 2022
## [26.8.3](v26.8.2...v26.8.3) (2022-08-15)

### Performance Improvements

* cache jest fn call parsing results ([#1187](#1187)) ([525631e](525631e))
@github-actions
Copy link

馃帀 This PR is included in version 26.8.3 馃帀

The release is available on:

Your semantic-release bot 馃摝馃殌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants