| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1471,6 +1471,7 @@ added: | |||
| 1471 | 1471 | --> | |
| 1472 | 1472 | ||
| 1473 | 1473 | Create a new instance of the `v8.GCProfiler` class. | |
| 1474 | + This API supports `using` syntax. | ||
| 1474 | 1475 | ||
| 1475 | 1476 | ### `profiler.start()` | |
| 1476 | 1477 | ||
@@ -1490,7 +1491,7 @@ added: | |||
| 1490 | 1491 | - v18.15.0 | |
| 1491 | 1492 | --> | |
| 1492 | 1493 | ||
| 1493 | - Stop collecting GC data and return an object.The content of object | ||
| 1494 | + Stop collecting GC data and return an object. The content of object | ||
| 1494 | 1495 | is as follows. | |
| 1495 | 1496 | ||
| 1496 | 1497 | ```json | |
@@ -1575,6 +1576,14 @@ setTimeout(() => { | |||
| 1575 | 1576 | }, 1000); | |
| 1576 | 1577 | ``` | |
| 1577 | 1578 | ||
| 1579 | + ### `profiler[Symbol.dispose]()` | ||
| 1580 | + | ||
| 1581 | + <!-- YAML | ||
| 1582 | + added: REPLACEME | ||
| 1583 | + --> | ||
| 1584 | + | ||
| 1585 | + Stop collecting GC data, and discard the profile. | ||
| 1586 | + | ||
| 1578 | 1587 | ## Class: `SyncCPUProfileHandle` | |
| 1579 | 1588 | ||
| 1580 | 1589 | <!-- YAML | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -488,6 +488,10 @@ class GCProfiler { | |||
| 488 | 488 | return JSONParse(data); | |
| 489 | 489 | } | |
| 490 | 490 | } | |
| 491 | + | ||
| 492 | + [SymbolDispose]() { | ||
| 493 | + this.stop(); | ||
| 494 | + } | ||
| 491 | 495 | } | |
| 492 | 496 | ||
| 493 | 497 | 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