-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make /v flag optional #6
Comments
What is the difference between verbose and non-verbose output? |
Normal output is:
Verbose output is (normal output plus):
Making the PS: Just writing a PR. :) PPS: Love your work. |
Another thought: How about adding a stream or even emitter interface? This would be nice for running the verbose option on slow systems, especially if you're not interested in all tasks anyway. |
Does |
Yeah, For a streaming implementation, I'm thinking about something along the lines of this ... const spawn = require('child_process').spawn
const Transform = require('stream').Transform
const csv = require('csv')
module.exports = () =>
spawn('tasklist.exe', ['/fo', 'csv'])
.stdout
.pipe(csv.parse({
columns: [ 'imageName', 'pid', 'sessionName', 'sessionNumber', 'memUsage' ],
from: 2 // skip header record
}))
.pipe(new Transform({
objectMode: true,
transform(task, encoding, callback) {
callback(null, Object.assign(task, {
pid: Number(task.pid),
sessionNumber: Number(task.sessionNumber),
memUsage: 1024 * Number(task.memUsage.replace(/[^\d]/g, ''))
}))
}
})) ... which could be used like this ... const tasklist = require('tasklist')
tasklist()
.on('data', console.log)
/* => { imageName: 'tasklist.exe',
pid: 9620,
sessionName: 'Console',
sessionNumber: 3,
memUsage: 864420 } */ Should this be part of this module, though? Or would it be better to put it in a new one, for example, |
If anyone reading this issue is interested in a streaming interface, check out |
tasklist
seems to be round about 1 second slower when used with the verbose flag. Therefore, I propose making the/v
flag optional.Using
timeit
from the Windows Server 2003 Resource Kit Tools, I got the following outputs:timeit tasklist
:timeit tasklist /v
:Hope I'm gonna be able to submit a PR soon. :)
EDIT: Just noticed there's already a closed issue regarding
tasklist
being slow: #4. It was closed as awontfix
. Making the/v
flag optional, however, would be that missing fix.Another question in this regard would be: Should the
verbose
option betrue
orfalse
by default? I'm leaning towardsfalse
considering the performance impact.The text was updated successfully, but these errors were encountered: