You can simply average out speed over longer period of time, like 30 seconds or more. Algorithm is very simple: keep track of what file size was at some time, for example every second in array. Then you can compute average speed over last 30 seconds by subtracting file size as of 30 seconds ago from current file size and dividing it by 30 seconds.
Another popular technique is to give more weight to more current measurements. For example, measurements over last 30 seconds are given weight 1
, over previous 30 seconds are given less weight (like 1/2
), then 1/4
and so on (you should probably stop at 1/8
or so). This way, old speed will still play some role, but will be quickly forgotten, and some dampening will still take place.
You should read about Trailing twelve months, it should give you some ideas how it works.