[whatwg] XHR Level 2: Accurate Speed Measurement
karld at opera.com
Wed Nov 23 18:06:09 PST 2011
Le 23 nov. 2011 à 10:14, Rodger Combs a écrit :
> XHR currently provides no reliable method of determining the actual upload or download speed of a transfer.
There's a lot of issues to be able to do something like this.
1. "reliable". The network is not reliable is the first issue.
All data you would get would be an estimate.
2. The network speed is usually not linear.
# XHR.timeRemaining = estimated time left in ms
Let's assume, we got the right content-length header.
The time remaining is a function of the download pattern which has already happened. An Integral to recalculate. Maybe a linear approximation is enough, not sure.
# XHR.completionTime = a Date object representing the estimated completion time
date.now() + XHR.timeRemaining is not ok?
# XHR.transferRate = upload/download speed, measured in Kbps, as an integer.
So you are saying the current transferRate or the integral of the past transferRate from the beginning?
Karl Dubost - http://dev.opera.com/
Developer Relations & Tools, Opera Software
More information about the whatwg