Skip to content

Normalized output (allow an option for non-human readable output) #6

@crozone

Description

@crozone

Overview

An option for normalized output in bytes (aka a non-human readable form) would allow for easier machine processing of the output.
For example, normalized results could be trivially plotted over time.

Currently the result is always printed in human readable form, which makes the magnitude of the numeric result change depending on its unit. Machine processing requires post-processing of the result in order to get it back into bps, which is cumbersome to do from the command line. The resultant line also includes additional whitespace prefixing, which makes processing in bash even more cumbersome.

Example

Example of current output:

$ fast-cli --simple
  47.19 Mbps

Example of normalized output:

$ fast-cli --simple --normalized
47190000

Workaround

Current workaround is to use numfmt (available in debian coreutils package):

$ fast-cli --simple | numfmt --from=auto --suffix=bps -d \n
47100000bps

However, this still includes a "bps" suffix which must be removed.

Changes

This would require parsing an additional argument, and adding an extra case in main.go:

fast-cli/main.go

Lines 161 to 163 in 7d2b485

} else {
fmt.Printf("%s\n", format.BitsPerSec(bandwidthMeter.Bandwidth()))
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions