perf_hooks: ignore duplicated entries in observer
PerformanceObserver should add to observing only unique entry types. PR-URL: https://github.com/nodejs/node/pull/29442 Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
This commit is contained in:
parent
6d01f1fa41
commit
ef9ecfbcfe
@ -354,6 +354,7 @@ class PerformanceObserver extends AsyncResource {
|
|||||||
for (var n = 0; n < entryTypes.length; n++) {
|
for (var n = 0; n < entryTypes.length; n++) {
|
||||||
const entryType = entryTypes[n];
|
const entryType = entryTypes[n];
|
||||||
const list = getObserversList(entryType);
|
const list = getObserversList(entryType);
|
||||||
|
if (this[kTypes][entryType]) continue;
|
||||||
const item = { obs: this };
|
const item = { obs: this };
|
||||||
this[kTypes][entryType] = item;
|
this[kTypes][entryType] = item;
|
||||||
L.append(list, item);
|
L.append(list, item);
|
||||||
|
@ -62,6 +62,12 @@ assert.strictEqual(counts[NODE_PERFORMANCE_ENTRY_TYPE_FUNCTION], 0);
|
|||||||
'for option "entryTypes"'
|
'for option "entryTypes"'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const obs = new PerformanceObserver(common.mustNotCall());
|
||||||
|
obs.observe({ entryTypes: ['mark', 'mark'] });
|
||||||
|
obs.disconnect();
|
||||||
|
performance.mark('42');
|
||||||
|
assert.strictEqual(counts[NODE_PERFORMANCE_ENTRY_TYPE_MARK], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test Non-Buffered
|
// Test Non-Buffered
|
||||||
|
Loading…
x
Reference in New Issue
Block a user