From: Junio C Hamano <gitster@pobox.com>
To: Petr Baudis <pasky@suse.cz>
Cc: Marcus Griep <marcus@griep.us>, Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] strbuf: Add method to convert byte-size to human readable form
Date: Thu, 14 Aug 2008 16:04:55 -0700 [thread overview]
Message-ID: <7viqu3ci5k.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <20080814223429.GC10544@machine.or.cz> (Petr Baudis's message of "Fri, 15 Aug 2008 00:34:29 +0200")
Petr Baudis <pasky@suse.cz> writes:
> My point still stands - in case of binary units, we should always
> consistently use the i suffix. So having an example in the commit
> message that advertises "bps" is simply wrong when it should read "iB/s"
> (like it does with the current progress.c code).
>
> I may sound boring, but it seems to me that you're still ignoring my
> point quitly without proper counter-argumentation and I think it's an
> important want, and since it's so hard to keep things consistent across
> the wide Git codebase, we should do all we can to keep it.
I pretty much agree with everything you said in this thread. In addition,
I wonder if we would want to be able to say:
960 bps
0.9 KiB/s
2.3 MiB/s
IOW, I do not think it is a good idea to have the list of "prefixes" in
this function and force callers to _append_ unit. You might be better off
by making the interface to the function to pass something like this:
struct human_unit {
char *unitname;
unsigned long valuescale;
} bps_to_human[] = {
{ "bps", 1 },
{ "KiB/s", 1024 },
{ "MiB/s", 1024 * 1024 },
{ NULL, 0 },
};
and perhaps give canned set of unit list for sizes and throughputs as
convenience.
By doing so, you could even do this:
struct human_unit bits_to_human[] = {
{ "bits", 1 },
{ "bytes", 8 },
{ "Kbytes", 8 * 1024 },
{ "Mbytes", 8 * 1024 * 1024 },
{ NULL, 0 },
};
I also am not particularly happy about using "double" in this API. Most
of the callers that gather stats in the rest of the codebase count in
(long) integers as far as I can tell, and it may be conceptually cleaner
to keep the use of double as an internal implementation issue of this
particular function.
next prev parent reply other threads:[~2008-08-14 23:06 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-14 22:18 [PATCH v2 0/3] count-objects size and strbuf human-readable Marcus Griep
2008-08-14 22:18 ` [PATCH v2 1/3] count-objects: Add total pack size to verbose output Marcus Griep
2008-08-14 22:18 ` [PATCH v2 2/3] strbuf: Add method to convert byte-size to human readable form Marcus Griep
2008-08-14 22:18 ` [PATCH v2 3/3] count-objects: add human-readable size option Marcus Griep
2008-08-14 22:37 ` Petr Baudis
2008-08-14 23:52 ` Marcus Griep
2008-08-15 0:10 ` Junio C Hamano
2008-08-14 22:34 ` [PATCH v2 2/3] strbuf: Add method to convert byte-size to human readable form Petr Baudis
2008-08-14 23:04 ` Junio C Hamano [this message]
2008-08-14 23:24 ` Petr Baudis
2008-08-14 23:40 ` Junio C Hamano
2008-08-15 0:53 ` Marcus Griep
2008-08-15 0:46 ` Marcus Griep
2008-08-15 0:52 ` Shawn O. Pearce
2008-08-15 4:20 ` [PATCH v3 1/3] count-objects: Add total pack size to verbose output Marcus Griep
2008-08-15 4:20 ` [PATCH v3 2/3] strbuf: Add method to convert byte-size to human readable form Marcus Griep
2008-08-15 4:20 ` [PATCH v3 3/3] count-objects: add human-readable size option Marcus Griep
2008-08-15 15:47 ` [PATCH v3.1 1/3] count-objects: Add total pack size to verbose output Marcus Griep
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7viqu3ci5k.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=marcus@griep.us \
--cc=pasky@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).