Differences From Artifact [5832428778]:
- File utils/ofhttp/ProgressBar.h — part of check-in [c7f0229795] at 2020-01-02 01:51:34 on branch trunk — Update copyright (user: js, size: 1074) [annotate] [blame] [check-ins using] [more...]
To Artifact [a9cb283e4e]:
- File
utils/ofhttp/ProgressBar.h
— part of check-in
[30e8df31a0]
at
2020-08-10 20:55:21
on branch trunk
— ofhttp: Average the speed over the last 10 seconds
This avoids the speed and hence also the ETA jumping like crazy on a
flaky connection. (user: js, size: 1181) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | * file. */ #import "OFObject.h" @class OFDate; @class OFTimer; @interface ProgressBar: OFObject { intmax_t _received, _lastReceived, _length, _resumedFrom; OFDate *_startDate, *_lastReceivedDate; OFTimer *_drawTimer, *_BPSTimer; bool _stopped; float _BPS; double _ETA; } - (instancetype)initWithLength: (intmax_t)length resumedFrom: (intmax_t)resumedFrom; - (void)setReceived: (intmax_t)received; - (void)draw; - (void)calculateBPSAndETA; - (void)stop; @end | > > > > | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | * file. */ #import "OFObject.h" @class OFDate; @class OFTimer; #define BPS_WINDOW_SIZE 10 @interface ProgressBar: OFObject { intmax_t _received, _lastReceived, _length, _resumedFrom; OFDate *_startDate, *_lastReceivedDate; OFTimer *_drawTimer, *_BPSTimer; bool _stopped; float _BPS; double _ETA; float _BPSWindow[BPS_WINDOW_SIZE]; size_t _BPSWindowIndex, _BPSWindowLength; } - (instancetype)initWithLength: (intmax_t)length resumedFrom: (intmax_t)resumedFrom; - (void)setReceived: (intmax_t)received; - (void)draw; - (void)calculateBPSAndETA; - (void)stop; @end |