mafintosh / mafintosh/speedometer

Calculated speed is wrong when buffer.length < size

Open
#8 0 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.