| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1463,6 +1463,7 @@ added: | |||
| 1463 | 1463 | --> | |
| 1464 | 1464 | ||
| 1465 | 1465 | Create a new instance of the `v8.GCProfiler` class. | |
| 1466 | + This API supports `using` syntax. | ||
| 1466 | 1467 | ||
| 1467 | 1468 | ### `profiler.start()` | |
| 1468 | 1469 | ||
@@ -1482,7 +1483,7 @@ added: | |||
| 1482 | 1483 | - v18.15.0 | |
| 1483 | 1484 | --> | |
| 1484 | 1485 | ||
| 1485 | - Stop collecting GC data and return an object.The content of object | ||
| 1486 | + Stop collecting GC data and return an object. The content of object | ||
| 1486 | 1487 | is as follows. | |
| 1487 | 1488 | ||
| 1488 | 1489 | ```json | |
@@ -1567,6 +1568,14 @@ setTimeout(() => { | |||
| 1567 | 1568 | }, 1000); | |
| 1568 | 1569 | ``` | |
| 1569 | 1570 | ||
| 1571 | + ### `profiler[Symbol.dispose]()` | ||
| 1572 | + | ||
| 1573 | + <!-- YAML | ||
| 1574 | + added: REPLACEME | ||
| 1575 | + --> | ||
| 1576 | + | ||
| 1577 | + Stop collecting GC data, and discard the profile. | ||
| 1578 | + | ||
| 1570 | 1579 | ## Class: `SyncCPUProfileHandle` | |
| 1571 | 1580 | ||
| 1572 | 1581 | <!-- YAML | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -486,6 +486,10 @@ class GCProfiler { | |||
| 486 | 486 | return JSONParse(data); | |
| 487 | 487 | } | |
| 488 | 488 | } | |
| 489 | + | ||
| 490 | + [SymbolDispose]() { | ||
| 491 | + this.stop(); | ||
| 492 | + } | ||
| 489 | 493 | } | |
| 490 | 494 | ||
| 491 | 495 | module.exports = { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,26 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + require('../common'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + const { GCProfiler } = require('v8'); | ||
| 6 | + | ||
| 7 | + { | ||
| 8 | + const profiler = new GCProfiler(); | ||
| 9 | + profiler.start(); | ||
| 10 | + | ||
| 11 | + const result = profiler[Symbol.dispose](); | ||
| 12 | + | ||
| 13 | + assert.strictEqual(result, undefined); | ||
| 14 | + assert.strictEqual(profiler.stop(), undefined); | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + { | ||
| 18 | + const profiler = new GCProfiler(); | ||
| 19 | + profiler.start(); | ||
| 20 | + | ||
| 21 | + profiler[Symbol.dispose](); | ||
| 22 | + // Repeat invocations should not throw | ||
| 23 | + profiler[Symbol.dispose](); | ||
| 24 | + | ||
| 25 | + assert.strictEqual(profiler.stop(), undefined); | ||
| 26 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments