jest icon indicating copy to clipboard operation
jest copied to clipboard

[Feature]: Expand perfStats to time test loading vs test execution

Open glenjamin opened this issue 1 year ago • 1 comments

🚀 Feature Proposal

In #14622 perfStats was expanded to provide breakdowns of parts of the test init process

However, it doesn't include a timer for the interval between calling import/require on the test file, and starting the actual test execution.

Motivation

In my experience this timing is a common cause of slow test suite execution, I'm currently exploring ways of collecting timing information about this phase, to help people target improvements in module loading for tests.

Example

No response

Pitch

This needs to live in core, as only jest-circus have the relevant context to be able to perform this timing.

I'm happy to submit a PR for this if I get the nod that the proposal makes sense

glenjamin avatar Oct 09 '24 14:10 glenjamin

I've been able to get something close enough to the correct numbers by reading the code closely and assigning slightly different meanings to the timestamps provided:

const {
  loadTestEnvironmentStart: testInitStart,
  setupAfterEnvEnd: testImportStart,
  end: testEnd,
} = testResult.perfStats;
const firstTestStart = testResult.testResults[0].startAt;

glenjamin avatar Oct 09 '24 14:10 glenjamin

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Nov 08 '24 15:11 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

github-actions[bot] avatar Dec 08 '24 16:12 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

github-actions[bot] avatar Dec 08 '24 16:12 github-actions[bot]

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

github-actions[bot] avatar Jan 08 '25 00:01 github-actions[bot]