-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
perf_hooks: make nodeTiming a first-class object #35977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
e0b8f00
7d64d79
170242b
166f6b3
778f60b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -165,51 +165,88 @@ function getMilestoneTimestamp(milestoneIdx) { | |
| return ns / 1e6 - timeOrigin; | ||
| } | ||
|
|
||
| const PerformanceNodeTimingProps = { | ||
| enumerable: true, | ||
| configurable: true | ||
| }; | ||
| class PerformanceNodeTiming extends PerformanceEntry { | ||
| get name() { | ||
| return 'node'; | ||
| } | ||
| constructor() { | ||
| super(); | ||
|
|
||
| get entryType() { | ||
| return 'node'; | ||
| } | ||
| ObjectDefineProperties(this, { | ||
| name: { | ||
| ...PerformanceNodeTimingProps, | ||
| value: 'node' | ||
| }, | ||
|
|
||
| get startTime() { | ||
| return 0; | ||
| } | ||
| entryType: { | ||
| ...PerformanceNodeTimingProps, | ||
| value: 'node' | ||
| }, | ||
|
|
||
| get duration() { | ||
| return now() - timeOrigin; | ||
| } | ||
| startTime: { | ||
| ...PerformanceNodeTimingProps, | ||
| value: 0 | ||
| }, | ||
|
|
||
| get nodeStart() { | ||
| return getMilestoneTimestamp(NODE_PERFORMANCE_MILESTONE_NODE_START); | ||
| } | ||
| duration: { | ||
| ...PerformanceNodeTimingProps, | ||
| get() { | ||
| return now() - timeOrigin; | ||
| } | ||
| }, | ||
|
|
||
| get v8Start() { | ||
| return getMilestoneTimestamp(NODE_PERFORMANCE_MILESTONE_V8_START); | ||
| } | ||
| nodeStart: { | ||
| ...PerformanceNodeTimingProps, | ||
| get() { | ||
| return getMilestoneTimestamp(NODE_PERFORMANCE_MILESTONE_NODE_START); | ||
| } | ||
| }, | ||
|
|
||
| get environment() { | ||
| return getMilestoneTimestamp(NODE_PERFORMANCE_MILESTONE_ENVIRONMENT); | ||
| } | ||
| v8Start: { | ||
| ...PerformanceNodeTimingProps, | ||
| get() { | ||
| return getMilestoneTimestamp(NODE_PERFORMANCE_MILESTONE_V8_START); | ||
| } | ||
| }, | ||
|
|
||
| get loopStart() { | ||
| return getMilestoneTimestamp(NODE_PERFORMANCE_MILESTONE_LOOP_START); | ||
| } | ||
| environment: { | ||
| ...PerformanceNodeTimingProps, | ||
| get() { | ||
| return getMilestoneTimestamp(NODE_PERFORMANCE_MILESTONE_ENVIRONMENT); | ||
| } | ||
| }, | ||
|
|
||
| get loopExit() { | ||
| return getMilestoneTimestamp(NODE_PERFORMANCE_MILESTONE_LOOP_EXIT); | ||
| } | ||
| loopStart: { | ||
| ...PerformanceNodeTimingProps, | ||
| get() { | ||
| return getMilestoneTimestamp(NODE_PERFORMANCE_MILESTONE_LOOP_START); | ||
| } | ||
| }, | ||
|
|
||
| get bootstrapComplete() { | ||
| return getMilestoneTimestamp(NODE_PERFORMANCE_MILESTONE_BOOTSTRAP_COMPLETE); | ||
| } | ||
| loopExit: { | ||
| ...PerformanceNodeTimingProps, | ||
| get() { | ||
| return getMilestoneTimestamp(NODE_PERFORMANCE_MILESTONE_LOOP_EXIT); | ||
| } | ||
| }, | ||
|
|
||
| get idleTime() { | ||
| return loopIdleTime(); | ||
| } | ||
| bootstrapComplete: { | ||
| ...PerformanceNodeTimingProps, | ||
| get() { | ||
| return getMilestoneTimestamp( | ||
| NODE_PERFORMANCE_MILESTONE_BOOTSTRAP_COMPLETE); | ||
| } | ||
| }, | ||
|
|
||
| idleTime: { | ||
| ...PerformanceNodeTimingProps, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking: I would just include the properties directly here (rather than use the repeated `...PerformanceNodeTimingProps) even if they're going to be duplicated just to save an unnecessary performance cost.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, do you think V8 keeps a reference to the initializing object when using the spread operator?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, this is ECMA specified in fact |
||
| get() { | ||
| return loopIdleTime(); | ||
| } | ||
| } | ||
| }); | ||
| } | ||
| [kInspect]() { | ||
| return { | ||
| name: 'node', | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.