mafintosh / mafintosh/speedometer
Calculated speed is wrong when buffer.length < size
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 91
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
When `buffer.length` is less than `size` (speedometer just started), calculated speed is incorrect, because it is averaged over the `buffer.length` rather than `size`. Take a look at this code:
```js
var s = require('speedometer')(120)
s(1) //1
s(1) //2
```
Speed equals 2, while it should be 2 / 120 (2 over 120 s window).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the speedometer entry point shown in the issue and trace how the initial buffer values are used to calculate speed. Reproduce the two-call example with a 120-second window, then verify that the result is divided by the configured size rather than the current buffer length.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- performance
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100