diff options
author | James M Snell <jasnell@gmail.com> | 2018-03-23 11:23:22 -0700 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2018-04-03 13:57:41 -0700 |
commit | 2ec69955556bf92f49355659b6126e08fa2c3298 (patch) | |
tree | 3164620ed2a629f083119f58fe75856b2ed401c3 /test/sequential | |
parent | d54f651910ffca2e50fad42dfec825d2339b1b6b (diff) | |
download | android-node-v8-2ec69955556bf92f49355659b6126e08fa2c3298.tar.gz android-node-v8-2ec69955556bf92f49355659b6126e08fa2c3298.tar.bz2 android-node-v8-2ec69955556bf92f49355659b6126e08fa2c3298.zip |
perf_hooks: simplify perf_hooks
Remove the `performance.getEntries()` and `performance.clear*()`
variants and eliminate the accumulation of the global timeline
entries. The design of this particular bit of the API is a memory
leak and performance footgun. The `PerformanceObserver` API is
a better approach to consuming the data in a more transient way.
PR-URL: https://github.com/nodejs/node/pull/19563
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'test/sequential')
-rw-r--r-- | test/sequential/test-performance.js | 59 |
1 files changed, 1 insertions, 58 deletions
diff --git a/test/sequential/test-performance.js b/test/sequential/test-performance.js index 037168dffb..ea7e17e18d 100644 --- a/test/sequential/test-performance.js +++ b/test/sequential/test-performance.js @@ -15,56 +15,12 @@ const inited = performance.now(); assert(inited < 20000); { - const entries = performance.getEntries(); - assert(Array.isArray(entries)); - assert.strictEqual(entries.length, 1); - assert.strictEqual(entries[0], performance.nodeTiming); -} - -{ - const entries = performance.getEntriesByName('node'); - assert(Array.isArray(entries)); - assert.strictEqual(entries.length, 1); - assert.strictEqual(entries[0], performance.nodeTiming); -} - -{ - let n; - let entries = performance.getEntries(); - for (n = 0; n < entries.length; n++) { - const entry = entries[n]; - assert.notStrictEqual(entry.name, 'A'); - assert.notStrictEqual(entry.entryType, 'mark'); - } + // Should work without throwing any errors performance.mark('A'); - entries = performance.getEntries(); - const markA = entries[1]; - assert.strictEqual(markA.name, 'A'); - assert.strictEqual(markA.entryType, 'mark'); performance.clearMarks('A'); - entries = performance.getEntries(); - for (n = 0; n < entries.length; n++) { - const entry = entries[n]; - assert.notStrictEqual(entry.name, 'A'); - assert.notStrictEqual(entry.entryType, 'mark'); - } -} -{ - let entries = performance.getEntries(); - for (let n = 0; n < entries.length; n++) { - const entry = entries[n]; - assert.notStrictEqual(entry.name, 'B'); - assert.notStrictEqual(entry.entryType, 'mark'); - } performance.mark('B'); - entries = performance.getEntries(); - const markB = entries[1]; - assert.strictEqual(markB.name, 'B'); - assert.strictEqual(markB.entryType, 'mark'); performance.clearMarks(); - entries = performance.getEntries(); - assert.strictEqual(entries.length, 1); } { @@ -83,11 +39,7 @@ assert(inited < 20000); }); }); - performance.clearMeasures(); performance.clearMarks(); - - const entries = performance.getEntries(); - assert.strictEqual(entries.length, 1); } { @@ -95,15 +47,6 @@ assert(inited < 20000); setImmediate(() => { performance.mark('B'); performance.measure('foo', 'A', 'B'); - const entry = performance.getEntriesByName('foo')[0]; - const markA = performance.getEntriesByName('A', 'mark')[0]; - performance.getEntriesByName('B', 'mark')[0]; - assert.strictEqual(entry.name, 'foo'); - assert.strictEqual(entry.entryType, 'measure'); - assert.strictEqual(entry.startTime, markA.startTime); - // TODO(jasnell): This comparison is too imprecise on some systems - // assert.strictEqual(entry.duration.toPrecision(3), - // (markB.startTime - markA.startTime).toPrecision(3)); }); } |