How to estimate download time remaining (accurately)?

前端 未结 7 1754
自闭症患者
自闭症患者 2020-11-28 01:13

Sure you could divide the remaining file size by the current download speed, but if your download speed fluctuates (and it will), this doesn\'t produce a very nice result.

7条回答
  •  攒了一身酷
    2020-11-28 01:59

    In extension to Ben Dolman's answer, you could also calculate the fluctuating within the algorithm. It will be more smooth, but it will also predict the avarage speed.

    Something like this:

    prediction = 50;
    depencySpeed = 200;
    stableFactor = .5;
    smoothFactor = median(0, abs(lastSpeed - averageSpeed), depencySpeed);
    smoothFactor /= (depencySpeed - prediction * (smoothFactor / depencySpeed));
    smoothFactor = smoothFactor * (1 - stableFactor) + stableFactor;
    averageSpeed = smoothFactor * lastSpeed + (1 - smoothFactor) * averageSpeed;
    

    Fluctuation or not, it will be both as stable as the other, with the right values for prediction and depencySpeed; you have to play with it a little depending on your internet speed. This settings are perfect for a avarage speed of 600 kB/s while it fluctuates from 0 to 1MB.

提交回复
热议问题