Skip to content

dotchev/cpu-gauge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm Build Status

cpu-gauge

Simple CPU usage metering for node

Wraps process.cpuUsage() in a simple to use interface. No need to multiply and divide to get CPU usage percentage.

Note: requires Node.js 6.1 or later.

Install

npm install --save cpu-gauge

Usage

const gauge = require('cpu-gauge');

var cpu = gauge.start();
// ...
console.log(cpu.usage().percent);

Note altough node executes JavaScript in a single thread, it uses additional threads for background tasks. So it is possible that CPU goes well above 100%.

API

gauge.start()

Starts metering the CPU usage. Returns a cpu object.

cpu.usage()

Returns CPU usage of current process since start() invocation. Returned object has the following properties:

  • user - user CPU time in microseconds
  • system - system CPU time in microseconds
  • time - elapsed time in microseconds
  • percent - CPU usage as percent of a logical core, so it could be above 100

About

Simple CPU usage metering for node

Resources

License

Stars

Watchers

Forks

Packages

No packages published