cpus
method of OS
module of node.js
Getting the information of all the cores/CPUs installed in your system using
cpus()
method of os
module of node.js as shown in
the snippet below:
//Name of the file : cpus.js
var os = require('os');
var value = os.cpus();
console.log("os.cpus() ==> " + JSON.stringify(value) );
>node cpus.js
os.cpus() ==> [{"model":"Intel(R) Core(TM) i3-2348M CPU @ 2.30GHz","speed":2294,
"times":{"user":3067572,"nice":0,"sys":1015862,"idle":12850535,"irq":149667}},{"
model":"Intel(R) Core(TM) i3-2348M CPU @ 2.30GHz","speed":2294,"times":{"user":5
95611,"nice":0,"sys":169822,"idle":16167943,"irq":4664}},{"model":"Intel(R) Core
(TM) i3-2348M CPU @ 2.30GHz","speed":2294,"times":{"user":3278049,"nice":0,"sys"
:813467,"idle":12841783,"irq":13572}},{"model":"Intel(R) Core(TM) i3-2348M CPU @
2.30GHz","speed":2294,"times":{"user":319786,"nice":0,"sys":80215,"idle":165331
57,"irq":967}}]