Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaling: automatic unit ? #197

Open
laurent-martin opened this issue Nov 13, 2024 · 1 comment
Open

Scaling: automatic unit ? #197

laurent-martin opened this issue Nov 13, 2024 · 1 comment

Comments

@laurent-martin
Copy link

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

@jfelchner
Copy link
Owner

I think this is a great idea. Do you want to try to implement it? ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants