Skip to content
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

add Bandwidth type #5

Merged
merged 1 commit into from
Oct 28, 2022
Merged

add Bandwidth type #5

merged 1 commit into from
Oct 28, 2022

Conversation

aead
Copy link
Owner

@aead aead commented Oct 28, 2022

This commit adds the Bandwidth type
that represents a Size per second.

We consider Bandwidth to be always normalized
to 1s. Most users will probably care only ever
about sizes per second, e.g. MB/s and not about
e.g. MB/ms.

Further, it is easy to add or subtract bandwidths. For example:

1.5MB/s = 1MB/s + 500KB/s

When dealing with arbitrary durations like 1MB/1.7ms a different type may be better suited:

type Rate struct {
  N Size
  T time.Duration
}

This commit adds the `Bandwidth` type
that represents a Size per second.

We consider `Bandwidth` to be always normalized
to 1s. Most users will probably care only ever
about sizes per second, e.g. MB/s and not about
e.g. MB/ms.

Further, it is easy to add or subtract bandwidths.
For example:
```
1.5MB/s = 1MB/s + 500KB/s
```

When dealing with arbitrary durations like 1MB/1.7ms
a different type may be better suited:
```
type Rate struct {
  N Size
  T time.Duration
}
```

Signed-off-by: Andreas Auernhammer <hi@aead.dev>
@aead aead merged commit e1563fe into main Oct 28, 2022
@aead aead deleted the bandwidth branch October 28, 2022 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant