Skip to content

Scaling: automatic unit ? #197

Closed
Closed
@laurent-martin

Description

@laurent-martin

Current Problem

I am displaying a transfer speed.
the units counted are bytes, so by default it's bytes/sec
the speed can very between a few kilobytes/s to Gigabytes/s
For the moment I settle on Mbps (mebibit/sec), so I divide by about 2^17.
But if the speed is less than 1Mbps, then it displays zero
and if the seed its > 1Gbps, it's many digits.

            format:      '%t %a %B %p%% %r Mbps %E',
            rate_scale:  lambda{|rate|rate / Environment::BYTES_PER_MEBIBIT},

Potential Solution or New Behavior

Well, It would be interesting to have a way to provide both the value and unit, something like:

        format:      '%t %a %B %p%% %R %E',
        rate_full:  lambda{|rate| "#{rate / Environment::BYTES_PER_MEBIBIT} Mbps"},

Then it's easy to adapt the whole value + unit in a single result.

Mockups

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