Comparing version 1.0.4 to 1.0.5
{ | ||
"name": "pidusage", | ||
"version": "1.0.4", | ||
"description": "Process cpu % and memory use of a PID", | ||
"version": "1.0.5", | ||
"description": "Cross-platform process cpu % and memory usage of a PID — Edit", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "dependencies": {}, |
@@ -7,7 +7,7 @@ pidusage | ||
Process cpu % and memory use of a PID | ||
Cross-platform process cpu % and memory usage of a PID — Edit | ||
Ideas from https://github.com/arunoda/node-usage/ but with no C-bindings | ||
# API | ||
## API | ||
@@ -33,3 +33,3 @@ ``` | ||
# What do this script do? | ||
## How it works | ||
@@ -43,5 +43,12 @@ A check on the `os.platform` is done to determine the method to use. | ||
Cpu usage is computed by following [those instructions](http://stackoverflow.com/questions/16726779/how-do-i-get-the-total-cpu-usage-of-an-application-from-proc-pid-stat/16736599#16736599). It keeps an history of the current processor time for the given pid so that the computed value gets more and more accurate. Don't forget to do `unmonitor(pid)` so that history gets cleared. | ||
Cpu usage does not check the child process tree! | ||
Memory result is representing the RSS (resident set size) only by doing `rss*pagesize`, where `pagesize` is the result of `getconf PAGE_SIZE`. | ||
### On darwin, freebsd, solaris (tested on 10/11) | ||
We use a fallback with the `ps -o pcpu,rss -p PID` command to get the same informations. | ||
We use a fallback with the `ps -o pcpu,rss -p PID` command to get the same informations. | ||
Memory usage will also display the RSS only, process cpu usage might differ from a distribution to another. Please check the correspoding `man ps` for more insights on the subject. | ||
### On AIX | ||
@@ -55,4 +62,19 @@ AIX is tricky because I have no AIX test environement, at the moment we use: `ps -o pcpu,rssize -p PID` but `/proc` results should be more accurate! If you're familiar with the AIX environment and know how to get the same results as we've got with Linux systems, please help. | ||
# Licence | ||
The memory usage here is what windows calls the "Working Set": | ||
> Maximum number of bytes in the working set of this process at any point in time. The working set is the set of memory pages touched recently by the threads in the process. If free memory in the computer is above a threshold, pages are left in the working set of a process even if they are not in use. When free memory falls below a threshold, pages are trimmed from working sets. If they are needed, they are then soft-faulted back into the working set before they leave main memory. | ||
For cpu usage, it's the "Percent Processor Time", which is about the same computation as it is done with linux implementations: | ||
> Returns elapsed time that all of the threads of this process used the processor to execute instructions in 100 nanoseconds ticks. An instruction is the basic unit of execution in a computer, a thread is the object that executes instructions, and a process is the object created when a program is run. Code executed to handle some hardware interrupts and trap conditions is included in this count. | ||
[Source](https://msdn.microsoft.com/en-us/library/windows/desktop/aa394323(v=vs.85).aspx) | ||
### Why `wmic`? I have the feeling it's slow | ||
This is the safest implementation I've found that works on most Windows version (>= XP). I've tried many other implementations but there was always some failing test case. For example, powershell would be faster but powershell needs to be attached to a console ([see this comment](https://github.com/nodejs/node-v0.x-archive/issues/8795#issuecomment-68068553)). This means it'd have to popup a new `cmd.exe` every time we execute `pidusage`. | ||
If you know a way that doesn't imply the use of `wmic`, please open an issue so that I can try it! | ||
## Licence | ||
MIT |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23137
77