Skip to content

dotchev/cpu-percentage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 cpu-percentage

Usage

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

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

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

The result is similar to

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

About

Get CPU usage percentage of own process

Resources

License

Stars

Watchers

Forks

Packages

No packages published