roar-pidusage
Advanced tools
+7
-16
@@ -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() |
+1
-1
| { | ||
| "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", |
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
23958
-1.51%423
-1.86%5
25%