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:12 UTC
Message-ID
<CALWbr2w=q=BkMOeqmSAbi50vNbup+e9GF0gdxNH9-vpyyND5Vw@mail.gmail.com>
In-Reply-To
<7vr4iikvkd.fsf@alter.siamese.dyndns.org>
On Wed, Apr 10, 2013 at 9:57 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 17 quoted lines
> Antoine Pelisse <apelisse@gmail.com> writes:
>
>> Currently, humanization of downloaded size is done in the same
>> function as text formatting in 'process.c'. This is an issue if anyone
>> else wants to use this.
>>
>> Separate text formatting from size simplification and make the function
>> public in strbuf so that it can easily be used by other clients.
>>
>> We now can use strbuf_humanize() for both downloaded size and download
>> speed calculation. One of the drawbacks is that speed will now look like
>> this when download is stalled: "0 bytes/s" instead of "0 KiB/s".
>
> Personally, I do not think the "drawback" is so big an issue.  If
> the caller really cares, we could always add another parameter to
> this formatter to tell it the minimum unit we care about (e.g. pass
> 1024 to say "Don't bother showing scale lower than kibi").
I thought about that, but decided it was not worth it (at least for the moment)
Show 5 quoted lines
> This is a bit late response, but if we ever want to count something
> in a dimention other than "bytes", like time (e.g. "kiloseconds") or
> number of commits (e.g. "centicommits"), etc., we cannot reuse this
> formatter very easily.  We may want to have "byte" somewhere in its
> name for now to make sure the callers understand its limitation.

I'm not in a hurry. But it look tough to make it generic: one is binary, another is sexagesimal, and the last is decimal

> I'll tentatively rename it to "strbuf_humanize_bytes()" while queuing.

I like the idea, Thanks,

Previous: Junio C HamanoNext: Eric Sunshine
Message 20 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.