lo1tuma / eslint-plugin-mocha

ESLint rules for mocha
MIT License
281 stars 61 forks source link

Use AST utils speed ups for more rules #279

Closed pasieronen closed 3 years ago

pasieronen commented 3 years ago

This PR applies the speed ups from b8fd70be also for no-identical-title, no-nested-tests, no-setup-in-describe and no-skipped-tests.

Results of time TIMING=1 npm run test:bench on my machine:

Before:

  runtime
    ✓ should not take longer as the defined budget to lint many files with the recommended config (91358ms)
    ✓ should not consume more memory as the defined budget to lint many files with the recommended config (90222ms)

  startup / require time
    ✓ should not take longer as the defined budget to require the plugin (755ms)
    ✓ should not consume more memory as the defined budget (720ms)

  4 passing (3m)

Rule                     | Time (ms) | Relative
:------------------------|----------:|--------:
no-setup-in-describe     | 32175.428 |    18.3%
no-nested-tests          | 24344.778 |    13.8%
no-identical-title       | 23523.293 |    13.4%
no-skipped-tests         | 15623.341 |     8.9%
no-hooks-for-single-case | 15192.657 |     8.6%
no-mocha-arrows          |  9966.165 |     5.7%
no-exports               |  9830.196 |     5.6%
no-async-describe        |  8221.952 |     4.7%
max-top-level-suites     |  8184.667 |     4.6%
no-global-tests          |  8141.928 |     4.6%

real    3m3.575s
user    3m5.368s
sys 0m2.117s

After:

  runtime
    ✓ should not take longer as the defined budget to lint many files with the recommended config (54985ms)
    ✓ should not consume more memory as the defined budget to lint many files with the recommended config (53322ms)

  startup / require time
    ✓ should not take longer as the defined budget to require the plugin (750ms)
    ✓ should not consume more memory as the defined budget (671ms)

  4 passing (2m)

Rule                     | Time (ms) | Relative
:------------------------|----------:|--------:
no-hooks-for-single-case | 15248.055 |    15.1%
no-setup-in-describe     | 11357.625 |    11.2%
no-mocha-arrows          |  9935.791 |     9.8%
no-exports               |  9835.281 |     9.7%
no-nested-tests          |  8539.599 |     8.4%
no-async-describe        |  8248.724 |     8.2%
no-sibling-hooks         |  8248.574 |     8.2%
max-top-level-suites     |  8236.007 |     8.1%
no-global-tests          |  8189.408 |     8.1%
no-top-level-hooks       |  8165.616 |     8.1%

real    1m50.250s
user    1m52.427s
sys 0m1.755s
pasieronen commented 3 years ago

Related to #268

pasieronen commented 3 years ago

Never mind, #280 is much better approach than tweaking individual rules one-by-one.