Skip to content

Instantly share code, notes, and snippets.

@GaetanoPiazzolla
GaetanoPiazzolla / avgLoad.js
Last active May 20, 2024 07:13
% CPU in Node.JS
const os = require("os");
//Create function to get CPU information
function cpuAverage() {
//Initialise sum of idle and time of cores and fetch CPU info
var totalIdle = 0, totalTick = 0;
var cpus = os.cpus();
//Loop through CPU cores