Re: [PATCH 1/2] strbuf: create strbuf_humanize() to show byte sizes
- From
Antoine Pelisse <apelisse@gmail.com>
- Date
- Apr 10, 2013, 20:00 UTC
- Message-ID
- <CALWbr2zciCO2Gzr_Hkg3oftYLtDkrPFrazP4HgRyPv=vYH5sXg@mail.gmail.com>
- In-Reply-To
- <20130410194307.GA27070@google.com>
On Wed, Apr 10, 2013 at 9:43 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 6 quoted lines
> Antoine Pelisse wrote: >> One of the drawbacks is that speed will now look like >> this when download is stalled: "0 bytes/s" instead of "0 KiB/s". > > At first glance that is neither obviously a benefit nor obviously a > drawback. Can you spell this out more?
The drawback to me is that it changes the user experience with no reason. But that's really a minor change, I agree. (maybe I should have put it as a comment/question after ---)
Show 14 quoted lines
>> --- a/Documentation/technical/api-strbuf.txt >> +++ b/Documentation/technical/api-strbuf.txt >> @@ -230,6 +230,11 @@ which can be used by the programmer of the callback as she sees fit. >> destination. This is useful for literal data to be fed to either >> strbuf_expand or to the *printf family of functions. >> >> +`strbuf_humanize`:: >> + >> + Append the given byte size as a human-readable string (i.e. 12.23 KiB, >> + 3.50 MiB). > > Based on the function name alone, it is not easy to guess what it will > do (e.g., maybe it will paraphrase 3 to "three" and 10000000 to > "enormous"). How about something like strbuf_filesize?
I think the suggestion from Junio makes more sense, as it can be used for download speed.
> If I understand the code correctly, this jumps units each time it > exceeds 1.0 of the next unit (bytes, KiB, MiB, GiB), which sounds like > a fine behavior.
The code has simply been extracted from the former function and kept unmodified.
Thanks for the help ! Antoine,