nodejs / nodejs/node

Slow performances when running tests with `--experimental-test-coverage`

Open
#55,103 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

coverage test_runner
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

Version

v22.9.0

Platform
Darwin N4V4PGFGPT 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:16:46 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T8112 arm64
Subsystem

No response

What steps will reproduce the bug?

Run tests with --experimental-test-coverage option. Comparing it to other solutions (f.e. running Node tests and getting the coverage with nyc) this is way slower. For instance, on a repo with ~800 tests, collecting coverage with nyc takes 77s, while running with --experimental-test-coverage takes 148s.

How often does it reproduce? Is there a required condition?

I can reproduce it every time I run the Node tests with the native test coverage option.

What is the expected behavior? Why is that the expected behavior?

The performances should be at least equal (ideally better) than with 3rd party dependencies (like nyc).

What do you see instead?

An average time spent per test of 185ms vs 96ms.

Additional information

I tried running with/without additional options (f.e. --test-coverage-exclude, --test-coverage-include, --test-coverage-branches, --test-coverage-functions, --test-coverage-lines) but it didn't help. The performance issue seems only to be related to the algorithm that's triggered by the --experimental-test-coverage option.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported timings with a test suite of roughly 800 tests, comparing --experimental-test-coverage with nyc and the listed coverage options. Trace the coverage algorithm triggered by the native option; done means coverage remains correct while its performance is substantially closer to the comparison.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
performance, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.