process.resourceUsage()
-
返回:<Object> 当前进程的资源使用情况。所有这些值都来自返回
uv_rusage_t结构 的uv_getrusage调用。¥Returns: <Object> the resource usage for the current process. All of these values come from the
uv_getrusagecall which returns auv_rusage_tstruct.-
userCPUTime<integer> 映射到以微秒计算的ru_utime。它与process.cpuUsage().user的值相同。¥
userCPUTime<integer> maps toru_utimecomputed in microseconds. It is the same value asprocess.cpuUsage().user. -
systemCPUTime<integer> 映射到以微秒计算的ru_stime。它与process.cpuUsage().system的值相同。¥
systemCPUTime<integer> maps toru_stimecomputed in microseconds. It is the same value asprocess.cpuUsage().system. -
maxRSS<integer> 映射到ru_maxrss,它是使用的最大驻留集大小,以千字节(1024 字节)为单位。¥
maxRSS<integer> maps toru_maxrsswhich is the maximum resident set size used in kibibytes (1024 bytes). -
sharedMemorySize<integer> 映射到ru_ixrss但不受任何平台支持。¥
sharedMemorySize<integer> maps toru_ixrssbut is not supported by any platform. -
unsharedDataSize<integer> 映射到ru_idrss但不受任何平台支持。¥
unsharedDataSize<integer> maps toru_idrssbut is not supported by any platform. -
unsharedStackSize<integer> 映射到ru_isrss但不受任何平台支持。¥
unsharedStackSize<integer> maps toru_isrssbut is not supported by any platform. -
minorPageFault<integer> 映射到ru_minflt,它是进程的次要页面错误数,请参阅 这篇文章了解更多详情。¥
minorPageFault<integer> maps toru_minfltwhich is the number of minor page faults for the process, see this article for more details. -
majorPageFault<integer> 映射到ru_majflt,这是进程的主要页面错误数,请参阅 这篇文章了解更多详情。Windows 不支持此字段。¥
majorPageFault<integer> maps toru_majfltwhich is the number of major page faults for the process, see this article for more details. This field is not supported on Windows. -
swappedOut<integer> 映射到ru_nswap但不受任何平台支持。¥
swappedOut<integer> maps toru_nswapbut is not supported by any platform. -
fsRead<integer> 映射到ru_inblock,这是文件系统必须执行输入的次数。¥
fsRead<integer> maps toru_inblockwhich is the number of times the file system had to perform input. -
fsWrite<integer> 映射到ru_oublock,这是文件系统必须执行输出的次数。¥
fsWrite<integer> maps toru_oublockwhich is the number of times the file system had to perform output. -
ipcSent<integer> 映射到ru_msgsnd但不受任何平台支持。¥
ipcSent<integer> maps toru_msgsndbut is not supported by any platform. -
ipcReceived<integer> 映射到ru_msgrcv但不受任何平台支持。¥
ipcReceived<integer> maps toru_msgrcvbut is not supported by any platform. -
signalsCount<integer> 映射到ru_nsignals但不受任何平台支持。¥
signalsCount<integer> maps toru_nsignalsbut is not supported by any platform. -
voluntaryContextSwitches<integer> 映射到ru_nvcsw,这是由于进程在其时间片完成之前(通常是为了等待资源可用)自愿放弃处理器而导致 CPU 上下文切换的次数。Windows 不支持此字段。¥
voluntaryContextSwitches<integer> maps toru_nvcswwhich is the number of times a CPU context switch resulted due to a process voluntarily giving up the processor before its time slice was completed (usually to await availability of a resource). This field is not supported on Windows. -
involuntaryContextSwitches<integer> 映射到ru_nivcsw,这是由于较高优先级进程变得可运行或因为当前进程超出其时间片而导致 CPU 上下文切换的次数。Windows 不支持此字段。¥
involuntaryContextSwitches<integer> maps toru_nivcswwhich is the number of times a CPU context switch resulted due to a higher priority process becoming runnable or because the current process exceeded its time slice. This field is not supported on Windows.
-
import { resourceUsage } from 'node:process';
console.log(resourceUsage());
/*
Will output:
{
userCPUTime: 82872,
systemCPUTime: 4143,
maxRSS: 33164,
sharedMemorySize: 0,
unsharedDataSize: 0,
unsharedStackSize: 0,
minorPageFault: 2469,
majorPageFault: 0,
swappedOut: 0,
fsRead: 0,
fsWrite: 8,
ipcSent: 0,
ipcReceived: 0,
signalsCount: 0,
voluntaryContextSwitches: 79,
involuntaryContextSwitches: 1
}
*/const { resourceUsage } = require('node:process');
console.log(resourceUsage());
/*
Will output:
{
userCPUTime: 82872,
systemCPUTime: 4143,
maxRSS: 33164,
sharedMemorySize: 0,
unsharedDataSize: 0,
unsharedStackSize: 0,
minorPageFault: 2469,
majorPageFault: 0,
swappedOut: 0,
fsRead: 0,
fsWrite: 8,
ipcSent: 0,
ipcReceived: 0,
signalsCount: 0,
voluntaryContextSwitches: 79,
involuntaryContextSwitches: 1
}
*/