nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
107.65k stars 29.62k forks source link

More benchmarks for the `node:test` module. #55723

Open RedYetiDev opened 3 days ago

RedYetiDev commented 3 days ago

The benchmark/test_runner folder currently contains benchmarks for it and describe functions. I suggest we expand these benchmarks to cover additional test runner features, including mocks, coverage, and various test modes.

Here are the functions that (IMO) should be benchmarked:

Basic Testing

These tests should run with a custom reporter without any special logic to make the tests as accurate as possible.

Hooks

Reporters (#55757)

Mocking

Snapshots

Coverage

Use --expose-internals to exclusively test the coverage part

cu8code commented 3 days ago

@RedYetiDev I'd love to work on this! Is there a guide or info page on how to create benchmarks? The issue also feels a bit vague — could we get an explicit list of functions to test?

RedYetiDev commented 3 days ago

IMHO we should start off simple.

How long does it take for a basic test to execute? What about a skipped test? A failing test? Etc.

For this to be as accurate as possible, we would probably need the benchmark to contain a custom reporter.

We could probably replace the current (limited) benchmark with this better idea I described above


From there, we could move on how long it takes specific parts, such as mocks, etc.

pmarchini commented 3 days ago

I was planning to start something related to coverage to enhance performance, and to do so, benchmarking is definitely needed. It would be great to use this issue to discuss and select a way forward(possibly with a division of the features to cover).

Do you have any ideas on how you would structure this? I think it's non-trivial to benchmark the test runner and coverage with precision, and I'm not sure if we already have anything similar in place.

RedYetiDev commented 3 days ago

My idea for coverage is to use the --expose-internals flag. We can calculate different forms of coverage, and just test the coverage function.

(I'll update the PR with an explicit list of functions/components later today–it's not a quick process)

RedYetiDev commented 3 days ago

I've added the list. If you think something else should be added, feel free to edit the issue