git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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,

Previous: Jonathan NiederNext: Junio C Hamano
Message 18 of 21 in “count-objects: output "KiB" instead of "kilobytes"”
  1. count-objects: output "KiB" instead of "kilobytes"Mihai Capotă, Apr 2, 2013
  2. Junio C HamanoApr 2, 2013
  3. Junio C HamanoApr 2, 2013
  4. Mihai CapotăApr 3, 2013
  5. count-objects: output "KiB" instead of "kilobytes"Mihai Capotă, Apr 3, 2013
  6. Junio C HamanoApr 3, 2013
  7. Mihai CapotăApr 4, 2013
  8. Junio C HamanoApr 4, 2013
  9. Mihai CapotăApr 5, 2013
  10. count-objects doc: document use of kibibytesMihai Capotă, Apr 5, 2013
  11. Antoine PelisseApr 5, 2013
  12. 1/2 progress: create public humanize() to show sizesAntoine Pelisse, Apr 8, 2013
  13. 2/2 count-objects: add -H option to humanize sizesAntoine Pelisse, Apr 8, 2013
  14. Junio C HamanoApr 8, 2013
  15. 1/2 strbuf: create strbuf_humanize() to show byte sizesAntoine Pelisse, Apr 10, 2013
  16. 2/2 count-objects: add -H option to humanize sizesAntoine Pelisse, Apr 10, 2013
  17. Jonathan NiederApr 10, 2013
  18. Antoine PelisseApr 10, 2013
  19. Junio C HamanoApr 10, 2013
  20. Antoine PelisseApr 10, 2013
  21. Eric SunshineApr 8, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.