node/test/parallel/test-perf-hooks-worker-timeorigin.js
legendecas a8c3d03df0
src: fix negative nodeTiming milestone values
PR-URL: https://github.com/nodejs/node/pull/46588
Fixes: https://github.com/nodejs/node/issues/45958
Refs: https://github.com/nodejs/node/pull/43781
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
2023-03-03 00:15:28 +08:00

21 lines
608 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const { Worker } = require('worker_threads');
const w = new Worker(`
require('worker_threads').parentPort.postMessage(performance.timeOrigin);
`, { eval: true });
w.on('message', common.mustCall((timeOrigin) => {
// PerformanceNodeTiming exposes process milestones so the
// `performance.timeOrigin` in the `worker_threads.Worker` must be the start
// time of the process.
assert.strictEqual(timeOrigin, performance.timeOrigin);
}));
w.on('exit', common.mustCall((code) => {
assert.strictEqual(code, 0);
}));