diff --git a/doc/api/v8.md b/doc/api/v8.md index 921c4378199496..7af37fba947e78 100644 --- a/doc/api/v8.md +++ b/doc/api/v8.md @@ -214,6 +214,32 @@ v8.setFlagsFromString('--trace_gc'); setTimeout(() => { v8.setFlagsFromString('--notrace_gc'); }, 60e3); ``` +## `v8.takeCoverage()` + + + +The `v8.takeCoverage()` method allows the user to write the coverage started by +[`NODE_V8_COVERAGE`][] to disk on demand. This method can be invoked multiple +times during the lifetime of the process, each time the execution counter will +be reset and a new coverage report will be written to the directory specified +by [`NODE_V8_COVERAGE`][]. + +When the process is about to exit, one last coverage will still be written to +disk, unless [`v8.stopCoverage()`][] is invoked before the process exits. + +## `v8.stopCoverage()` + + + +The `v8.stopCoverage()` method allows the user to stop the coverage collection +started by [`NODE_V8_COVERAGE`][], so that V8 can release the execution count +records and optimize code. This can be used in conjunction with +`v8.takeCoverage()` if the user wants to collect the coverage on demand. + ## `v8.writeHeapSnapshot([filename])`