Socket
Socket
Sign inDemoInstall

cpu-percentage

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cpu-percentage

Get CPU usage percentage of own process


Version published
Weekly downloads
706
decreased by-0.84%
Maintainers
1
Install size
4.03 kB
Created
Weekly downloads
 

Readme

Source

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 }

Keywords

FAQs

Last updated on 12 Nov 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc