Add benchmarks for node only mode and mock timers.#64097
Open
luanmuniz wants to merge 1 commit into
Open
Conversation
The only benchmark covers creating selected and non-selected tests when running with --test-only. The mock timers benchmark covers enabling timer mocks, setTimeout, setInterval, setImmediate, scheduler.wait, AbortSignal.timeout, mocked Date.now(), setTime(), and runAll(). Refs: nodejs#55723 Signed-off-by: Luan Muniz <luan@luanmuniz.com.br>
Collaborator
|
Review requested:
|
RafaelGSS
reviewed
Jun 23, 2026
|
|
||
| for (let i = 0; i < selected; i++) { | ||
| test(`selected-${i}`, { only: true }, () => { | ||
| avoidV8Optimization = i; |
Member
There was a problem hiding this comment.
This is unnecessary; it's a clojure. Adding an assert.ok is probably more useful.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds another small set of
node:testbenchmarks for areas listed in #55723.A continuation of the work I started in #63754
This is a different PR because it brings a different set of attention points, and to keep both PR easy to review.
This PR covers:
onlymode with--test-onlymock.timers.enable()setTimeoutsetIntervalsetImmediatescheduler.waitAbortSignal.timeoutDate.now()mock.timers.setTime()mock.timers.runAll()Notes
enable()+reset()instead of just enable. This happens because an error is thrown if enable is called multiple times without reset.scheduler.waitmode includes the finalPromise.all()inside the measured section. My evaluation was that it was more appropriate to do so than not, since the scheduled waits are promise-based, but I am happy to adjust the structure if reviewers prefer a narrower measure.Issue found while writing this
TLDR: I found an issue (that doesn't affect this PR) with using
setImmediateandrunAlltogether while writing the benchmark; guidance welcome;While writing the benchmark, I found that
setImmediatedoesn't work withrunAll(). The mocked setImmediate is scheduled with a special-1time so it runs before zero-delay timers.runAll()computeslongestTimer.runAt - this.#nowinmock_timers.js:816, which becomes-1, andtick()rejects negative time in mock_timers.js:556.I would love to open a new PR to fix this issue, but this is beyond my context of how the team working on this operates and what they think would be an appropriate fix. If the person reviewing the PR could provide some guidance on the best way to handle this issue, it would be much appreciated.
This issue doesn't impact this PR, all benchmarks still work with the current code (With tick(0) instead of runAll() for setImmediate).