JSPM

cpu-percentage

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 34989
  • Score
    100M100P100Q143140F
  • License MIT

Get CPU usage percentage of own process

Package Exports

  • cpu-percentage

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cpu-percentage) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Build Status npm

cpu-percentage

Get CPU usage percentage of own process

  • Uses JavaScript only and node API (process.cpuUsage).
  • No native code.
  • No external processes.

Note: requires node 6.1 or later.

See also cpu-gauge.

Install

npm install -S cpu-percentage

Usage

In this example we measure the CPU usage while loading a text file.

var usage = require('cpu-percentage');
var fs = require('fs');

var start = usage();
fs.readFile(__filename, 'utf8', function(err, data) {
  console.log(usage(start));
});

The result is similar to

{ user: 8000, system: 4000, time: 9, percent: 133.33333333333334 }