Overview
| Comment: | ofhttp: Average the speed over the last 10 seconds
This avoids the speed and hence also the ETA jumping like crazy on a |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
30e8df31a07b8d68c1080f4ca296e17c |
| User & Date: | js on 2020-08-10 20:55:21 |
| Other Links: | manifest | tags |
References
|
2020-08-10
| ||
| 21:38 | • Fixed ticket [037c915376]: utils/ofhttp Average the speed and ETA plus 3 other changes (artifact: 7657e3e37e user: js) | |
Context
|
2020-08-11
| ||
| 00:30 | configure: Use AC_CONFIG_FILES conditionally (check-in: 7ac3c91102 user: js tags: trunk) | |
|
2020-08-10
| ||
| 20:55 | ofhttp: Average the speed over the last 10 seconds (check-in: 30e8df31a0 user: js tags: trunk) | |
|
2020-07-19
| ||
| 16:12 | OFNumber: Add singletons for 0, 1, 2, true & false (check-in: d8123a1f26 user: js tags: trunk) | |
Changes
Modified utils/ofhttp/ProgressBar.h from [5832428778] to [a9cb283e4e].
| ︙ | ︙ | |||
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
|
Modified utils/ofhttp/ProgressBar.m from [813833df71] to [530e773cf6].
| ︙ | ︙ | |||
252 253 254 255 256 257 258 |
[self _drawProgress];
else
[self _drawReceived];
}
- (void)calculateBPSAndETA
{
| > | > > > > > > > > > | 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
[self _drawProgress];
else
[self _drawReceived];
}
- (void)calculateBPSAndETA
{
_BPSWindow[_BPSWindowIndex++ % BPS_WINDOW_SIZE] =
(float)(_received - _lastReceived) /
-(float)_lastReceivedDate.timeIntervalSinceNow;
if (_BPSWindowLength < BPS_WINDOW_SIZE)
_BPSWindowLength++;
_BPS = 0;
for (size_t i = 0; i < _BPSWindowLength; i++)
_BPS += _BPSWindow[i];
_BPS /= _BPSWindowLength;
_ETA = (double)(_length - _received) / _BPS;
_lastReceived = _received;
[_lastReceivedDate release];
_lastReceivedDate = [[OFDate alloc] init];
}
|
| ︙ | ︙ |