Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

AdaptiveTransferSpeed is not adaptive #122

Copy link
Copy link

Description

@tobiasmaier
Issue body actions

Description

AdaptiveTransferSpeed shows the same values as TransferSpeed, it does not calculate the values over the last X samples.

The example code below shows when finished:

100% ETA: Time: 0:00:15 Adaptive ETA: Time: 0:00:15 Absolute ETA: Finished at: 0:00:15 Transfer Speed: 33.3 B/s Adaptive Transfer Speed: 33.3 B/s ||

the expected Adaptive Transfer Speed with sleep(0.1) for the last 100 iterations would be 10.0 B/s

The reason is FileTransferSpeed is used to print Adaptive Transfer Speed but calculated and passed parameters value and total_seconds_elapsed are ignored because the keys exist in data.

value = data['value'] or value
elapsed = data['total_seconds_elapsed'] or total_seconds_elapsed

Proposed Fix

Change the code in FileTransferSpeed.__call__ to

value = value or data['value']
elapsed = total_seconds_elapsed or data['total_seconds_elapsed']

or to be have the same code as in ETA.__call__ to:

if value is None:
    value = data['value']
if elapsed is None:
    elapsed = data['total_seconds_elapsed']

Code

Copied from examples and added FileTransferSpeed widget

import progressbar
from time import sleep

widgets = [
    progressbar.Percentage(),
    ' ETA: ', progressbar.ETA(),
    ' Adaptive ETA: ', progressbar.AdaptiveETA(),
    ' Absolute ETA: ', progressbar.AbsoluteETA(),
    ' Transfer Speed: ', progressbar.FileTransferSpeed(),
    ' Adaptive Transfer Speed: ', progressbar.AdaptiveTransferSpeed(),
    ' ', progressbar.Bar(),
]
bar = progressbar.ProgressBar(widgets=widgets, max_value=500)
bar.start()
for i in range(500):
    if i < 100:
        sleep(0.02)
    elif i > 400:
        sleep(0.1)
    else:
        sleep(0.01)
    bar.update(i + 1)
bar.finish()

Versions

  • Python version: 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609]
  • Python distribution/environment: CPython
  • Operating System: Ubuntu Linux
  • Package version: 3.20.0 / git
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.