soyuka / pidusage

Cross-platform process cpu % and memory usage of a PID
MIT License
512 stars 55 forks source link

What happened between version 2.0.15 and 2.0.16? #81

Closed alexstrat closed 6 years ago

alexstrat commented 6 years ago

I was very surprised to figure out that between 2.0.15 and 2.0.16 the CPU computation had drastically changed:

With test-pidusage.js
// test-pidusage.js
var WHATEVER_PID = 45966;
var pidusage = require('pidusage')
setInterval(function () {
  pidusage(WHATEVER_PID, function (err, stats) {
    console.log(stats.cpu)
  })
}, 1000)
$ npm install pidusage@2.0.16
$ node test-pidusage.js
8
3
7.000000000000001
33
44
19
2
12
18
10
11
4
11
36
25
15
9
2
8
28.999999999999996
27
6
22
11

$ npm install pidusage@2.0.15
$ node test-pidusage.js
480
240
60
120
120
120
240
1440
1320
1019.9999999999999
-3200
1860.0000000000002
-3320.0000000000005
1019.9999999999999
420

There is no clue in your repository about what could have happened: no code, no changelog..

Can you please clarify?

soyuka commented 6 years ago

Hi,

I'm assuming that you're on os x? Between 2.0.15 and 2.0.16 we patched a wrong time value. For more details see #79. It's also linked to negative values https://github.com/soyuka/pidusage/issues/69.

https://github.com/soyuka/pidusage/commit/bcda538b76498c6d4bcaa36520238990554929c5

alexstrat commented 6 years ago

Yes, forgot to mention I'm on OSX. Ok good to know, thanks!

Other than asking you — I may have missed something but — there are no way of figuring this out:

pidusage is fairly popular with 200k dl/week, but, on the other hand, I can imagine that maintaining an OS library is not your job. Having a CHANGELOG updated on every release is actually a small amount of work that, I think, would be very appreciated by the community.

Anyway, closing this issue as I had my answer. Thanks for your work 😀

soyuka commented 6 years ago

I can imagine that maintaining an OS library is not your job

I wish :). About versions bump with no commits I use 3 computers daily, and I often just use npm version patch && npm publish without git push && git push --tags creating weird differences between commits and npm versions when I switch computer. I know it's bad and I'll try to take my time when releasing to avoid such issues in commits!

In the meantime I've updated the changelog.

alexstrat commented 6 years ago

🎉👌 Thanks!