[PATCH v3 1/3] eal: add function rte_size_to_str
Morten Brørup
mb at smartsharesystems.com
Thu Mar 13 11:07:47 CET 2025
> > +{
> > + const char *prefix = "kMGTPE";
>
> Why is "k" in lower case compared to the others all in upper-case?
That's what the standardization bodies decided. Let's stick with that!
> > + * Sample outputs with "use_iec" disabled and enabled:
> > + * 0 : "0 ", "0 "
> > + * 700 : "700 ", "700 "
> > + * 1000 : "1.00 k", "1000 "
> > + * 1024 : "1.02 k", "1.00 ki"
> > + * 21474836480 : "21.5 G", "20.0 Gi"
> > + * 109951162777600 : "110 T", "100 Ti"
> > + *
>
> I would omit the space before the suffixes in the output. As well as
> looking better to me, it also solves the issue of the non-suffixed
> numbers
> having a trailing space.
The space could be optional, like the "use_iec" parameter.
I would certainly expect the space when appending a unit, e.g. "bit/s":
"700 bit/s" or "1.00 kbit/s".
Or when the appended unit is seconds, e.g. for latency/jitter:
"12.3 ms" or "123 us".
With raw numbers (i.e. without a unit appended), it's probably a matter of personal preference, so I'm not going to insist here.
I still prefer it, but only when a postfix is present.
In the SmartShare GUI, we output with the space, and accept input both with and without it.
More information about the dev
mailing list