Skip to content
This repository has been archived by the owner on Aug 23, 2019. It is now read-only.

Commit

Permalink
fix(stats): prevent 0ms timeDiff breaking movingAverage (#336)
Browse files Browse the repository at this point in the history
* stats - stat - prevent 0ms timeDiff breaking movingAverage

* chore: remove commitlint
  • Loading branch information
kumavis authored and jacobheun committed Apr 25, 2019
1 parent c73efba commit 7aebb9c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:

- stage: check
script:
- npx aegir commitlint --travis
- npx aegir dep-check
- npm run lint

Expand Down
4 changes: 3 additions & 1 deletion src/stats/stat.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ class Stats extends EventEmitter {
_updateFrequencyFor (key, timeDiffMS, latestTime) {
const count = this._frequencyAccumulators[key] || 0
this._frequencyAccumulators[key] = 0
const hz = (count / timeDiffMS) * 1000
// if `timeDiff` is zero, `hz` becomes Infinity, so we fallback to 1ms
const safeTimeDiff = timeDiffMS || 1
const hz = (count / safeTimeDiff) * 1000

let movingAverages = this._movingAverages[key]
if (!movingAverages) {
Expand Down

0 comments on commit 7aebb9c

Please sign in to comment.