-
Notifications
You must be signed in to change notification settings - Fork 55
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
Complete code refactor #49
Conversation
+ fix darwin
Fix array when pid has not been found
I don't think so. (Sorry to be rude)
This is the reason why we need to have rock-solid tests for this fundamental module
See https://github.com/soyuka/pidusage/pull/49/files#r175304248
I've tried do it when possible.
The developer doesn't know when it's appropriate to clean the history. You should consider history as an internal optimization of the problem that you should need to call wmic twice. Then instead of calling twice always you save the last reading. We may want to discuss about the max age time, but I believe this is the way to go.
What are the advantages of tap?
Let's end the work and the I will take care of that. |
Mhh so, if I call pidusage with an array of pids and one of them isn't found. Will this give back partial results AND an error?
Less noise, less fancy just good ol' non-breaking working for years stuff :). Sure thing let's keep this fancy ava thing... Good work on the README it works like that for me! So left to do:
Thanks for your work, looks great so far! |
lib/ps.js
Outdated
@@ -7,7 +7,7 @@ var PLATFORM = os.platform() | |||
|
|||
function parseTime (timestr, fraction) { | |||
var time = 0 | |||
var tpart = timestr.replace(/-|\./g, ':').split(':') | |||
var tpart = timestr.split(/-|:|\./) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now yours faster :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎊How much is improved?
index.js
Outdated
return pify(stats, pids) | ||
} | ||
|
||
module.exports = pidusage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just did that as well haha. let me rebase... We could've done this in another patch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry! 🙈
This is the biggest PR I ever done.
It was really a pleasure to collaborate with u
Should we need to document how it works under the hood?
That's the current behaviour if you pass an array of pids. That's the default behaviour of ps and wmic also |
Also lets consider to enables services like EG: |
- Now windows time readings are now correct (time is 100-ns units not in ms) - The history for wmic readings now is a LRU cache that auto-expire after 1 min of inactivity to avoid memory leaks - CPU usage on windows should now be more accurate. If there isn't any history for a given pid, then the measurement is took twice. - The start property of the statistics object has been removed. Actually it was completely wrong. (BREAKING CHANGE) - The time property has been renamed to ctime that means cpu time. (BREAKING CHANGE) - The elapsed has been added. It's the time in ms since the process has been started. (BREAKING CHANGE) - The timestamp property has been added. It's the time at which we took the measure. (BREAKING CHANGE) The unmonitor and _history functions exported from the index.js has been complitely removed. Now we export just the stat funtion (BREAKING CHANGE) - Tests are re-implemented and improved using ava - Coverage report with nyc added - Over-simplified the readme.md (We may want to re-add some documentation on how it works) - Update .gitignore file - Cleaned package.json file - procfile implementation has been completely removed (We may consider to re-introduce this in the future if we will need it, but now is useless) - The ppid property has been added. Await for child to be spawned before start the test Extend old readings when reading twice with wmic Improve windows spawn options Sort array before comparison in test Fix child script Add legend to the compatibility table Fix child script Fix unresolved promis in tests Fix test Normalize cpu usage Add PPID Fix timezone calc Add missing base to parseInt and parseFloat Improve parseTime performance Improve bench creation performance Add missing 'use strict' Use single interval for history expiration Fix clearInterval for history Remove duplicated benchmark Improve lint script Fix codestyle Fix compatibility table Fix heading Update authors section Update API section Update usage section Update dependencies constraints Update api section Update readme Update readme Fix related section Fix error message Improve error messages Improve error messages Improve error messages Improve error messages Improve stdout parsing performance Improve documentation Return promise if no callback is provided Close #50
@soyuka can you create a PR with the changes you want on my fork instead of working on your branch Then we will squash commits while merging this. |
- Now windows time readings are now correct (time is 100-ns units not in ms) - The history for wmic readings now is a LRU cache that auto-expire after 1 min of inactivity to avoid memory leaks - CPU usage on windows should now be more accurate. If there isn't any history for a given pid, then the measurement is took twice. - The start property of the statistics object has been removed. Actually it was completely wrong. (BREAKING CHANGE) - The time property has been renamed to ctime that means cpu time. (BREAKING CHANGE) - The elapsed has been added. It's the time in ms since the process has been started. (BREAKING CHANGE) - The timestamp property has been added. It's the time at which we took the measure. (BREAKING CHANGE) The unmonitor and _history functions exported from the index.js has been complitely removed. Now we export just the stat funtion (BREAKING CHANGE) - Tests are re-implemented and improved using ava - Coverage report with nyc added - Over-simplified the readme.md (We may want to re-add some documentation on how it works) - Update .gitignore file - Cleaned package.json file - procfile implementation has been completely removed (We may consider to re-introduce this in the future if we will need it, but now is useless) - The ppid property has been added. Commits: Extend old readings when reading twice with wmic Normalize cpu usage Add PPID Fix timezone calc Add missing base to parseInt and parseFloat Improve parseTime performance Improve bench creation performance Use single interval for history expiration Improve lint script Update readme Improve error messages Improve stdout parsing performance Improve documentation Return promise if no callback is provided Close #50
I squashed and merged in #51 !! Thank you very much for the work, I'll open maybe a couple more merge requests this week to keep improving while I'm working on Unitech/pm2#3546 ! |
@soyuka I cannot see the changes for the readme. I believe that something went wrong while merging |
Oh yes thanks, was a mess to rebase because you merged master back to your branch. Prefer rebase next time :). All good now I think! Note that I removed benchmarks from CI because it was 1,2 minute per number of test versions and that's a lot. |
I activated https://codecov.io/gh/soyuka/pidusage not sure if I should configure something |
Yes you should add |
Changes
Sorry for this but I've almost rewrote the entire package. 🙈❤️
start
property of the statistics object has been removed. Actually it was completely wrong. (BREAKING CHANGE)time
property has been renamed toctime
that means cpu time. (BREAKING CHANGE)elapsed
has been added. It's the time in ms since the process has been started. (BREAKING CHANGE)timestamp
property has been added. It's the time at which we took the measure. (BREAKING CHANGE)unmonitor
and_history
functions exported from theindex.js
has been complitely removed. Now we export just the stat funtion (BREAKING CHANGE)ava
nyc
addedreadme.md
(We may want to re-add some documentation on how it works).gitignore
filepackage.json
fileprocfile
implementation has been completely removed (We may consider to re-introduce this in the future if we will need it, but now is useless)ppid
property has been added.I can understand that maybe is too much but I need this package to work.
If you are unhappy with the changes let me know! Thanks!
You can walk though the code here