feat(tools-performance): Add @rnx-kit/tools-performance package#4079
Open
feat(tools-performance): Add @rnx-kit/tools-performance package#4079
Conversation
tido64
reviewed
Apr 9, 2026
Comment on lines
+73
to
+77
| } else { | ||
| for (const cat of category) { | ||
| this.enabled.add(cat); | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
We should probably also check that category is an actual array:
Suggested change
| } else { | |
| for (const cat of category) { | |
| this.enabled.add(cat); | |
| } | |
| } | |
| } else if (Array.isArray(category)) { | |
| for (const cat of category) { | |
| this.enabled.add(cat); | |
| } | |
| } else { | |
| throw new Error(`invalid category: ${category}`); | |
| } |
…/jasonvmo/tools-perf
…/jasonvmo/tools-perf
tido64
approved these changes
Apr 13, 2026
| @@ -0,0 +1,221 @@ | |||
| import { styleText } from "util"; | |||
Member
There was a problem hiding this comment.
Suggested change
| import { styleText } from "util"; | |
| import { styleText } from "node:util"; |
Comment on lines
+43
to
+45
| if (this.exitHandlers) { | ||
| this.exitHandlers.delete(callback); | ||
| } |
Member
There was a problem hiding this comment.
Suggested change
| if (this.exitHandlers) { | |
| this.exitHandlers.delete(callback); | |
| } | |
| this.exitHandlers?.delete(callback); |
| */ | ||
| stop(processExit = false) { | ||
| // first attempt to close the initial start event if it exists | ||
| if (this.startVal !== undefined) { |
Member
There was a problem hiding this comment.
This supports both null/undefined and is shorter:
Suggested change
| if (this.startVal !== undefined) { | |
| if (this.startVal != null) { |
| private timingRecorder(tag: string, startTime?: number) { | ||
| const timeNow = performance.now(); | ||
| tag = this.coerceTag(tag); | ||
| if (startTime === undefined) { |
Member
There was a problem hiding this comment.
Suggested change
| if (startTime === undefined) { | |
| if (startTime == null) { |
|
|
||
| private markingRecorder(tag: string, startMark?: string) { | ||
| tag = this.coerceTag(tag); | ||
| if (startMark === undefined) { |
Member
There was a problem hiding this comment.
Suggested change
| if (startMark === undefined) { | |
| if (startMark == null) { |
| if (intlFormatter) { | ||
| text = intlFormatter.format(value); | ||
| } else { | ||
| text = digits !== undefined ? value.toFixed(digits) : String(value); |
Member
There was a problem hiding this comment.
Suggested change
| text = digits !== undefined ? value.toFixed(digits) : String(value); | |
| text = digits != null ? value.toFixed(digits) : String(value); |
| text ??= String(value); | ||
| key = text; | ||
| } | ||
| if (maxWidth !== undefined && text.length > maxWidth) { |
Member
There was a problem hiding this comment.
Suggested change
| if (maxWidth !== undefined && text.length > maxWidth) { | |
| if (maxWidth != null && text.length > maxWidth) { |
| completions: 0, | ||
| total: 0, | ||
| }; | ||
| if (duration !== undefined) { |
Member
There was a problem hiding this comment.
Suggested change
| if (duration !== undefined) { | |
| if (duration != null) { |
| if (reportSort && reportSort.length > 0) { | ||
| for (const sortCol of reportSort) { | ||
| const index = cols.indexOf(sortCol); | ||
| if (index !== -1) { |
Member
There was a problem hiding this comment.
Ensure positive index:
Suggested change
| if (index !== -1) { | |
| if (index >= 0) { |
Comment on lines
+167
to
+171
| const rows = Array.from(this.timings.values()).map( | ||
| (entry: OperationData) => { | ||
| return cols.map((col: PerfReportColumn) => getCellValue(entry, col)); | ||
| } | ||
| ); |
Member
There was a problem hiding this comment.
Can we use .forEach instead of Array.from to avoid the temporary array?
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.
Description
This adds a framework for doing lightweight performance tracing, some basic reporting, and enabling tracing at a global level.
Usage
In packages, to add instrumentation:
Right now, to enable this for metro bundling a user would add in their metro.config.js:
Future things to add (or consider)
Other notes