提交 4816a253 编写于 作者: J Johannes Rieken

Revert "use PerformanceObserver in node's perf-util"

This reverts commit 05c4659e.
上级 05c4659e
......@@ -72,32 +72,11 @@ function _define() {
}
} else if (typeof process === 'object') {
// node.js: use "node-native" performance for mark()
// and setup a PerformanceObserver for getMarks()
const { performance, PerformanceObserver } = (require.nodeRequire || require)('perf_hooks');
// node.js: use the normal polyfill but add the timeOrigin
// from the node perf_hooks API as very first mark
const timeOrigin = Math.round((require.nodeRequire || require)('perf_hooks').performance.timeOrigin);
return _definePolyfillMarks(timeOrigin);
const marks = [];
const obs = new PerformanceObserver(list => { marks.push(list.getEntries()); });
obs.observe({ entryTypes: ['mark'], buffered: true });
return {
mark(name) {
performance.mark(name);
},
getMarks() {
const timeOrigin = performance.timeOrigin;
const result = [{ name: 'code/timeOrigin', startTime: Math.round(timeOrigin) }];
for (const array of marks) {
for (const entry of array) {
result.push({
name: entry.name,
startTime: Math.round(timeOrigin + entry.startTime)
});
}
}
return result;
}
};
} else {
// unknown environment
console.trace('perf-util loaded in UNKNOWN environment');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册