mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
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:
1 parent
9b4a49c844
commit
c146fff307
2 files changed
+7
No files matched your search
@@ -354,6 +354,7 @@ class PerformanceObserver extends AsyncResource {
|
||||
for (var n = 0; n < entryTypes.length; n++) {
|
||||
const entryType = entryTypes[n];
|
||||
const list = getObserversList(entryType);
|
||||
if (this[kTypes][entryType]) continue;
|
||||
const item = { obs: this };
|
||||
this[kTypes][entryType] = item;
|
||||
L.append(list, item);
|
||||
|
||||
@@ -62,6 +62,12 @@ assert.strictEqual(counts[NODE_PERFORMANCE_ENTRY_TYPE_FUNCTION], 0);
|
||||
'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
|
||||
|
||||
Reference in new issue
Block a user