Skip to content

Commit

Permalink
fixup! use performance.nodeTiming instead
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelGSS committed Aug 20, 2024
1 parent aa4dc99 commit 6654a2b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 25 deletions.
8 changes: 8 additions & 0 deletions lib/internal/perf/nodetiming.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const {
NODE_PERFORMANCE_MILESTONE_ENVIRONMENT,
},
loopIdleTime,
uvMetricsInfo,
} = internalBinding('performance');

class PerformanceNodeTiming {
Expand Down Expand Up @@ -122,6 +123,13 @@ class PerformanceNodeTiming {
configurable: true,
get: loopIdleTime,
},

uvMetricsInfo: {
__proto__: null,
enumerable: true,
configurable: true,
get: uvMetricsInfo,
}

Check failure on line 132 in lib/internal/perf/nodetiming.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Missing trailing comma
});
}

Expand Down
10 changes: 0 additions & 10 deletions lib/internal/perf/performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const {
} = require('internal/perf/observe');

const { eventLoopUtilization } = require('internal/perf/event_loop_utilization');
const { uvMetricsInfo } = require('internal/perf/uv_metrics');
const nodeTiming = require('internal/perf/nodetiming');
const timerify = require('internal/perf/timerify');
const { customInspectSymbol: kInspect, kEnumerableProperty, kEmptyObject } = require('internal/util');
Expand Down Expand Up @@ -158,7 +157,6 @@ class Performance extends EventTarget {
nodeTiming: this.nodeTiming,
timeOrigin: this.timeOrigin,
eventLoopUtilization: this.eventLoopUtilization(),
uvMetrics: this.uvMetricsInfo(),
};
}
}
Expand Down Expand Up @@ -193,14 +191,6 @@ ObjectDefineProperties(Performance.prototype, {
writable: true,
value: eventLoopUtilization,
},
uvMetricsInfo: {
__proto__: null,
configurable: true,
// Node.js specific extensions.
enumerable: false,
writable: true,
value: uvMetricsInfo,
},

nodeTiming: {
__proto__: null,
Expand Down
11 changes: 0 additions & 11 deletions lib/internal/perf/uv_metrics.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ const assert = require('node:assert');
const fs = require('node:fs');
const { performance } = require('node:perf_hooks');

const { uvMetricsInfo } = performance;
const { nodeTiming } = performance;

function safeMetricsInfo(cb) {
setImmediate(() => {
const info = uvMetricsInfo();
const info = nodeTiming.uvMetricsInfo;
cb(info);
});
}

{
const info = uvMetricsInfo();
const info = nodeTiming.uvMetricsInfo;
assert.strictEqual(info.loopCount, 0);
assert.strictEqual(info.events, 0);
// This is the only part of the test that we test events waiting
Expand All @@ -33,7 +33,7 @@ function safeMetricsInfo(cb) {
// The synchronous call should obviously not affect the uv metrics
const fd = fs.openSync(filepath, 'r');
fs.readFileSync(fd);
const info = uvMetricsInfo();
const info = nodeTiming.uvMetricsInfo;
assert.strictEqual(info.loopCount, 0);
assert.strictEqual(info.events, 0);
assert.strictEqual(info.eventsWaiting, 0);
Expand Down

0 comments on commit 6654a2b

Please sign in to comment.