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

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"name": "cpu-percentage",
"version": "1.0.0",
"version": "1.0.1",
"description": "Get CPU usage percentage of own process",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -13,1 +13,27 @@ [![Build Status](https://travis-ci.org/dotchev/cpu-percentage.svg?branch=master)](https://travis-ci.org/dotchev/cpu-percentage)

**Note:** requires node 6.1 or later.
## Install
```sh
npm install -S cpu-usage
```
## Usage
In this example we measure the CPU usage while loading a text file.
```js
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 }
```
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