🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

roar-pidusage

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

roar-pidusage - npm Package Compare versions

Comparing version
1.1.6
to
1.1.7
+7
-16
lib/stats.js

@@ -122,4 +122,3 @@ var os = require('os')

// http://social.msdn.microsoft.com/Forums/en-US/469ec6b7-4727-4773-9dc7-6e3de40e87b8/cpu-usage-in-for-each-active-process-how-is-this-best-determined-and-implemented-in-an?forum=csharplanguage
//var args = 'PROCESS ' + pid + ' get workingsetsize,usermodetime,kernelmodetime'
var args = 'path win32_perfformatteddata_perfproc_process where (IDProcess = '+ pid +') get Name, Caption, PercentProcessorTime, WorkingSetPeak, IDProcess /format:list'
var args = 'PROCESS ' + pid + ' get peakworkingsetsize,usermodetime,kernelmodetime'

@@ -158,19 +157,11 @@ var wmic = spawn('wmic', args.split(' '), {detached: true})

stdout = stdout.split(os.EOL)
stdout = stdout.split(os.EOL)[1].replace(/\s\s+/g, ' ').split(' ')
var stats = {
cpu: 0,
workingsetsize: 0,
kernelmodetime: parseFloat(stdout[0]),
usermodetime: parseFloat(stdout[1]),
}
stdout.forEach(function(line) {
if (line.indexOf('PercentProcessorTime') === 0) {
stats.cpu = +line.split('=')[1].trim();
} else if (line.indexOf('WorkingSetPeak') === 0) {
stats.workingsetsize = +line.split('=')[1].trim();
}
})
var workingsetsize = parseFloat(stdout[2])
/*var workingsetsize = parseFloat(stdout[2])
//process usage since last call

@@ -183,3 +174,3 @@ var total = stats.kernelmodetime - (history.kernelmodetime || 0) + stats.usermodetime - (history.usermodetime || 0)

seconds = Math.abs(seconds)
seconds = seconds === 0 ? 1 : seconds //we sure can't divide through 0*/
seconds = seconds === 0 ? 1 : seconds //we sure can't divide through 0

@@ -189,3 +180,3 @@ self.history[pid] = stats

return done(null, {cpu: stats.cpu, memory: stats.workingsetsize})
return done(null, {cpu: (total / seconds) * 100, memory: workingsetsize})
})

@@ -192,0 +183,0 @@ wmic.stdin.end()

{
"name": "roar-pidusage",
"version": "1.1.6",
"version": "1.1.7",
"description": "Cross-platform process cpu % and memory usage of a PID — Edit",

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