diff --git a/doc/api/process.md b/doc/api/process.md index 1cb946aa2579c7..efffa85b7b7f5b 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -421,6 +421,29 @@ added: v0.7.2 If `process.connected` is false, it is no longer possible to send messages. +## process.cpuUsage([previousValue]) + +Returns the user and system CPU time usage of the current process, in an object +with properties `user` and `system`, whose values are microsecond values +(millionth of a second). These values measure time spent in user and +system code respectively, and may end up being greater than actual elapsed time +if multiple CPU cores are performing work for this process. + +The result of a previous call to `process.cpuUsage()` can be passed as the +argument to the function, to get a diff reading. + +```js +const startUsage = process.cpuUsage(); +// { user: 38579, system: 6986 } + +// spin the CPU for 500 milliseconds +const now = Date.now(); +while (Date.now() - now < 500); + +console.log(process.cpuUsage(startUsage)); +// { user: 514883, system: 11226 } +``` + ## process.cwd()