fix(perf_hooks): make Performance.measure() second and third params optional#6092
Merged
fix(perf_hooks): make Performance.measure() second and third params optional#6092
Conversation
…ptional
This change aligns the Performance.measure() API with the Web Performance
API specification and Node.js behavior:
1. Make measureOptionsOrStartMark parameter optional (was required)
- Calling measure(name) now works and measures from timeOrigin (0) to now
- Previously this would fail due to the required second parameter
2. Fix detail property to default to null instead of synthetic object
- Per MDN and Node.js, detail should be null when not explicitly provided
- Previously we were creating a synthetic {start, end} object
- This is technically a breaking change but aligns with the standard
References:
- MDN: https://developer.mozilla.org/en-US/docs/Web/API/Performance/measure
- Node.js: https://github.com/nodejs/node/blob/main/lib/internal/perf/usertiming.js
jasnell
approved these changes
Feb 17, 2026
anonrig
approved these changes
Feb 17, 2026
|
The generated output of |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6092 +/- ##
==========================================
- Coverage 70.56% 70.54% -0.02%
==========================================
Files 409 409
Lines 108957 108955 -2
Branches 18010 18013 +3
==========================================
- Hits 76883 76866 -17
- Misses 21269 21287 +18
+ Partials 10805 10802 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
logan-gatlin
pushed a commit
to logan-gatlin/workerd
that referenced
this pull request
Feb 19, 2026
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.
Summary
This PR aligns the
Performance.measure()API with the Web Performance API specification and Node.js behavior by:measureOptionsOrStartMark) optional someasure(name)worksdetailproperty to default tonullinstead of a synthetic{start, end}objectChanges
1. Optional Parameters
The
measure()method now supports being called with just a name:When called with only a name, it measures from
timeOrigin(0) to the current time.2. Detail Property Fix
Per the MDN spec and Node.js implementation,
detailshould benullwhen not explicitly provided.Before:
detailwas set to{start: <startTime>, end: <endTime>}even when not requestedAfter:
detailisnullunless explicitly provided via optionsBreaking Change Note
The change to
detaildefaulting tonullis technically a breaking change for code that relied on the synthetic detail object. However, this aligns with the web standard and Node.js behavior.Testing
testPerformanceMeasureNameOnlyfor single-parameter usagedetailisnullwhen not provideddetailproperty when not provided