- /* The progress bar is supposed to display the "current download
- speed". The first version of the progress bar calculated it by
- dividing the total amount of data with the total time needed to
- download it. The problem with this was that stalled or suspended
- download could unduly influence the "current" time. Taking just
- the time needed to download the current packet would not work
- either because packets arrive too fast and the varitions would be
- too jerky.
-
- It would be preferrable to show the speed that pertains to a
- recent period, say over the past several seconds. But to do this
- accurately, we would have to record all the packets received
- during the last five seconds.
-
- What we do instead is maintain a history of a fixed number of
- packets. It actually makes sense if you think about it -- faster
- downloads will have a faster response to speed changes. */
-
- rec_index = bp->recent.count % RECENT_ARRAY_SIZE;
- ++bp->recent.count;
+ /* This code attempts to determine the current download speed. We
+ measure the speed over the interval of approximately three
+ seconds, in subintervals no smaller than 0.1s. In other words,
+ we maintain and use the history of 30 most recent reads, where a
+ "read" consists of one or more network reads, up until the point
+ where a subinterval is filled. */