mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
worker: add cpuUsage for worker
PR-URL: https://github.com/nodejs/node/pull/59177 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ilyas Shabi <ilyasshabi94@gmail.com>
This commit is contained in:
parent
0bbe7c36c9
commit
0ba6e0d7ce
9 changed files with 225 additions and 1 deletions
|
@ -1760,6 +1760,19 @@ added: v10.5.0
|
|||
The `'online'` event is emitted when the worker thread has started executing
|
||||
JavaScript code.
|
||||
|
||||
### `worker.cpuUsage([prev])`
|
||||
|
||||
<!-- YAML
|
||||
added:
|
||||
- REPLACEME
|
||||
-->
|
||||
|
||||
* Returns: {Promise}
|
||||
|
||||
This method returns a `Promise` that will resolve to an object identical to [`process.threadCpuUsage()`][],
|
||||
or reject with an [`ERR_WORKER_NOT_RUNNING`][] error if the worker is no longer running.
|
||||
This methods allows the statistics to be observed from outside the actual thread.
|
||||
|
||||
### `worker.getHeapSnapshot([options])`
|
||||
|
||||
<!-- YAML
|
||||
|
@ -2123,6 +2136,7 @@ thread spawned will spawn another until the application crashes.
|
|||
[`process.stderr`]: process.md#processstderr
|
||||
[`process.stdin`]: process.md#processstdin
|
||||
[`process.stdout`]: process.md#processstdout
|
||||
[`process.threadCpuUsage()`]: process.md#processthreadcpuusagepreviousvalue
|
||||
[`process.title`]: process.md#processtitle
|
||||
[`require('node:worker_threads').isMainThread`]: #workerismainthread
|
||||
[`require('node:worker_threads').parentPort.on('message')`]: #event-message
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue