标签:model OLE 系统 cpu div mem pre use const
获取操作系统相关信息
const os = require(‘os‘)
获取当前机器的CPU信息
console.log(os.cpus())
打印结果:
[ { model: ‘Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz‘, speed: 2300, times: { user: 1332960, nice: 0, sys: 928720, idle: 5905010, irq: 0 } }, { model: ‘Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz‘, speed: 2300, times: { user: 684730, nice: 0, sys: 490170, idle: 6991300, irq: 0 } }, { model: ‘Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz‘, speed: 2300, times: { user: 1315900, nice: 0, sys: 741750, idle: 6108540, irq: 0 } }, { model: ‘Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz‘, speed: 2300, times: { user: 596770, nice: 0, sys: 406270, idle: 7163160, irq: 0 } } ]
获取当前机器的内存总量,单位为字节
console.log(os.totalmem())
打印结果:
17179869184
单位为字节,除以1024为KB,再除以1024为MB,再除以1024为GB(上面的结果为16GB)
标签:model OLE 系统 cpu div mem pre use const
原文地址:https://www.cnblogs.com/lianglanlan/p/12144377.html