-
Notifications
You must be signed in to change notification settings - Fork 2
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
Provide a set of common throughput calculation functions #116
Comments
@littlespex I'd like to implement those functions, if no one picked it up yet. I already looked at I saw some network-related calculations, such as current throughput based on Connection API, time calculations (i.e. Bps/Kbps, ms/s), etc I'll have another look at |
For dash.js please also check the new I think we also need to distinguish between ways to access the current throughput/required information like using the Network Information API, Resource Timing API etc and actually calculating/estimating the current throughput using methods like EWMA, Harmonic Mean, Arithmetic Mean etc. |
in |
Overall, the majority of OSS players are aligned with the exception that |
1st version of a high-level design: // Generic utilities
type ValueOf<T> = T[keyof T];
const ThroughputCalculationType = {
EMWA: 'emwa',
ZLEMA: 'zlema'
} as const;
type ThroughputCalculationType = ValueOf<typeof ThroughputCalculationType>;
// Calculation API
interface ThroughputCalculationState {
estimate: number;
sample: number[];
sampleSize: number;
}
type ThroughputCalculation = (
state: ThroughputCalculationState
) => number;
// Factory API
interface ThroughputCalculationFactoryOptions {
type: ThroughputCalculationType;
}
declare const throughputCalculationFactory: (
options: ThroughputCalculationFactoryOptions
) => ThroughputCalculationFactory; A journey (from bottom to top):
TS Playground for you to see the whole picture - https://tsplay.dev/w6DJYm With this solution, there is no "Adding points to the state" API As possible alternative, I've extended Another solution is to have a separate function to process data, e.g. of a type CC @littlespex |
I'm still reviewing this, but a few questions:
|
@littlespex answering your questions below:
This depends on whether the configurable parameter is static or dynamic. (1) If it's dynamic, it has to be a part of (2) If it's static, it has to be moved to I believe that
I completely agree.
I'd like to elaborate on my decision. Let's have a look at the high-level requirements and evaluate the benefits/disadvantages. The requirements are:
A pure function:
A function with a mutation:
I know that it doesn't make sense to prematurely optimise the solution, therefore I'm open to suggestions.
Yes, you're right. If we agree that the SlidingWindow and ThroughputCalculator APIs are compatible, we will be able to compose these 2 functions to get the expected result. |
Provide a set of common throughput calculation functions like ewma, slidingWindow, etc.
The text was updated successfully, but these errors were encountered: