@svta/common-media-library
Version:
A common library for media playback in JavaScript
24 lines • 566 B
JavaScript
import { getBandwidthBps } from '../utils/getBandwidthBps.js';
/**
* Harmonic Mean throughput estimator
*
* @group Throughput
*
* @beta
*/
export class HarmonicMeanEstimator {
constructor() {
this.samples = [];
}
sample(sample) {
this.samples.push(sample);
}
getEstimate() {
let value = 0;
for (let i = 0; i < this.samples.length; i++) {
value += 1 / getBandwidthBps(this.samples[i]);
}
return this.samples.length / value;
}
}
//# sourceMappingURL=HarmonicMeanEstimator.js.map