Skip to content

Commit

Permalink
calculateThroughputByChunkData() fixes (#4130)
Browse files Browse the repository at this point in the history
* Add reset of shortDurationStartTime after chunkThroughputs.push()

- shortDurationStartTime need to be reset after a
  chunkThroughputs.push() otherwise it can lead to spurious
  'short duration' throughput measurements.
- Moved reset of shortDurationBytesReceived to more optimal location so
  it is only reset when shortDurationStartTime === 0

* Included length of last piece of short duration data in throughput calculation

- The length (byte count) of the final piece of 'short duration'
  data should be included in the throughput calculation otherwise
  it is ignored which leads to an underestimate.
  • Loading branch information
piersoh authored Mar 7, 2023
1 parent 553ecc0 commit 7330851
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/streaming/net/FetchLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,14 +426,16 @@ function FetchLoader(cfg) {
let chunkDownloadTime = datumE[i].ts - datum[i].ts;
if (chunkDownloadTime > 1) {
chunkThroughputs.push((8 * datumE[i].bytes) / chunkDownloadTime);
shortDurationStartTime = 0;
} else {
if (shortDurationStartTime === 0) {
shortDurationStartTime = datum[i].ts;
shortDurationBytesReceived = 0;
}
let cumulatedChunkDownloadTime = datumE[i].ts - shortDurationStartTime;
if (cumulatedChunkDownloadTime > 1) {
shortDurationBytesReceived += datumE[i].bytes;
chunkThroughputs.push((8 * shortDurationBytesReceived) / cumulatedChunkDownloadTime);
shortDurationBytesReceived = 0;
shortDurationStartTime = 0;
} else {
// continue cumulating short duration data
Expand Down

0 comments on commit 7330851

Please sign in to comment.