measure your CPU load
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

A simple tool for measuring the CPU load

A simple tool that will start a timer that ticks every 15 ms by default. Everytime it ticks, the current timestamp is saved in an array. When you stop the timer, you can get a report that tells how many time the timer ticked, and when. If the JS runtime was overloaded at the same time, some ticks will be lost are will splipped.

Note that the accuarcy of the measure is very poor, so it's worth repeating the measure several times and to compare it to a base measure. Even without doing anything, 5% of the ticks will be missed.

npm install js-cpu-load

##Initialising the tool

var Measure = require("js-cpu-load");

// By default, the timer will be set to 15 ms
var measure = new Measure();

// It can be configured
var measure = new Measure(30); // 30 ms

##Using the tool

// Start timer

// Stop timer

// Report measure;

// Reset timer, before starting it again

// Get only the collected data

// Change the timer
measure.setInterval(30); // 30 ms

##The actual measure;


data {Array} array of timestamps
dataFromStart {Array} timestamps relative to the start time
startTime {Number} timestamp when the measure started
stopTime {Number} timestamp when the measure stopped
count {Number} the number of ticks
expectedCount {Number} the theoretical number of count