public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Nathan Sidwell <nathan@acm.org>
To: marxin <mliska@suse.cz>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 4/7] GCOV: add -j argument (human readable format).
Date: Mon, 30 Oct 2017 12:44:00 -0000	[thread overview]
Message-ID: <afb320b4-3491-2bec-4e93-b377d72a56d9@acm.org> (raw)
In-Reply-To: <64ee387ade24b20ee9a6bc2a038abd6664800a61.1509005504.git.mliska@suse.cz>

On 10/26/2017 04:11 AM, marxin wrote:
> Human readable format is quite useful in my opinion. There's example:
> 
>          -:    1:unsigned
>     14.00K:    2:loop (unsigned n, int value)

My first thought is 'why 2 decimal places'?  That seems excessive.  Zero 
surely suffices?

> Question is do we want to do it by default, or a new option is fine?
> Note that all external tools using gcov should use intermediate format
> which is obviously unchanged.

I don't think other tools do it by default.


> +     [@option{-j}|@option{--human-numbers}]

man ls:
       -h, --human-readable
               with -l and/or -s, print human readable sizes (e.g., 1K 
234M 2G)

Sadly '-h' is help (IIRC).  but we could at least copy the long form.


> +  const char *units[] = {"", "K", "M", "G", "Y", "P", "E", "Z"};

Those aren't right  KMGTPEZY
http://www.npl.co.uk/reference/measurement-units/si-prefixes/


> +  for (unsigned i = 0; i < sizeof (units); i++)
> +    {
> +      if (v < 1000.0f)
> +	{
> +	  sprintf (buffer, "%3.2f%s", v, units[i]);
> +	  return buffer;
> +	}
> +
> +      v /= 1000.0f;
> +    }

that's going to fail on certain roundings.  You're doing multiple 
divisions by 1000, which itself will have roundings.  But more 
importantly, numbers after scaling like 999.999 will round to 1000, and 
you probably don't want that.  This kind of formatting is tricky.  My 
inclination is to keep it in the integer domain.  Determine a scaling 
factor.  Divide once by that and then explicitly round to nearest 
even[*] with a check for the 999.9 case.  Then print as an unsigned.

nathan

[*] I presume you're familiar with RNE?  That's probably overkill and 
plain RN would be adequate.

-- 
Nathan Sidwell

  reply	other threads:[~2017-10-30 12:35 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-26  8:12 [PATCH 0/7] GCOV: another set of improvements marxin
2017-10-26  8:12 ` [PATCH 7/7] GCOV: std::vector refactoring III marxin
2017-10-30 14:23   ` Nathan Sidwell
2017-10-26  8:12 ` [PATCH 3/7] GCOV: add support for lines with an unexecuted lines marxin
2017-10-30 12:27   ` Nathan Sidwell
2017-10-31 11:29     ` Martin Liška
2017-11-02 15:33   ` Eric Botcazou
2017-10-26  8:12 ` [PATCH 2/7] GCOV: introduce usage of terminal colors marxin
2017-10-30 12:20   ` Nathan Sidwell
2017-10-30 14:53     ` David Malcolm
2017-10-31 11:14       ` Martin Liška
2017-10-26  8:12 ` [PATCH 4/7] GCOV: add -j argument (human readable format) marxin
2017-10-30 12:44   ` Nathan Sidwell [this message]
2017-10-31 11:54     ` Martin Liška
2017-10-31 12:10       ` Nathan Sidwell
2017-10-31 14:04         ` Martin Liška
2017-10-31 14:39           ` Nathan Sidwell
2017-10-31 15:33             ` Martin Liška
2017-10-26  8:12 ` [PATCH 1/7] GCOV: document behavior of -fkeep-{static,inline}-functions (PR gcov-profile/82633) marxin
2017-10-30 12:17   ` Nathan Sidwell
2017-10-31 11:12     ` Martin Liška
2017-10-26  8:12 ` [PATCH 5/7] GCOV: std::vector refactoring marxin
2017-10-30 14:17   ` Nathan Sidwell
2017-10-26  8:19 ` [PATCH 6/7] GCOV: Vector refactoring II marxin
2017-10-30 14:19   ` Nathan Sidwell
2017-10-26  8:47 ` [PATCH 8/N][RFC] GCOV: support multiple functions per a line Martin Liška
2017-10-26 12:06   ` Nathan Sidwell
2017-11-01  8:00     ` [PATCH 8/N][RFC] v2 " Martin Liška
2017-11-07 10:53       ` [PATCH 8/N][RFC][v3]: " Martin Liška
2017-11-07 15:09         ` Nathan Sidwell
2017-11-08 11:42           ` Martin Liška
2017-11-08 15:12             ` Nathan Sidwell
2017-11-09  9:47               ` Martin Liška

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=afb320b4-3491-2bec-4e93-b377d72a56d9@acm.org \
    --to=nathan@acm.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mliska@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 read-only IMAP folder(s) and NNTP newsgroup(s).