From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 70506 invoked by alias); 30 Oct 2017 12:35:16 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 70475 invoked by uid 89); 30 Oct 2017 12:35:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=Human, scaling, 9999 X-HELO: mail-yw0-f175.google.com Received: from mail-yw0-f175.google.com (HELO mail-yw0-f175.google.com) (209.85.161.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 30 Oct 2017 12:35:13 +0000 Received: by mail-yw0-f175.google.com with SMTP id k11so11378102ywh.1 for ; Mon, 30 Oct 2017 05:35:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Er3u14SWQ4Z1hpOPjvggCqoqmHD9Jxn3UEozziryPxc=; b=L9+ZfWKiniHaDIHLXyYYtMkrTF3rPl20cmjbOmqcfrQYNSrPp1z0nwbYYirrhrSdOX NVZx5wlPWuDHKCOXXsKjyToV4Iiw0+FYqgBZQqP2mDSwk/8XtKavNlPmMp5kX6Rf2ZmY sIt5QVrrROyzIsZDXPuU+qVCvAkK1mh/7wqECjs2qFiVgX6hy5Uq5nt0MXSC/SKPo5XH izOXAzSQEBhMQ5fnMPMCJC+KzqWlvs3ngdm4r7UCq24IZI1qHDahqCKyCYmayjFFjJpp eUlZuRR2jSsiu+r8rommoWke6hX3pTDAj4E1NmvbfIZcGdDoNpkxX+QvA15IRZkkIRZZ xxBg== X-Gm-Message-State: AMCzsaXZYGgBxiD+XtBvvJcgHu0ATzXW4IqLUUkcU5xlWKrowBz3ya/a WgE/S582QprYNlFX9wcKLqY= X-Google-Smtp-Source: ABhQp+RDNTtdHY5fXlBvcyhEAQMHkZ+mPCegLONLR7/5QtACRja92h1JzvueII78dGRu2pgmQ8S5qA== X-Received: by 10.13.210.6 with SMTP id u6mr6003935ywd.301.1509366911602; Mon, 30 Oct 2017 05:35:11 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::3:68fe]) by smtp.googlemail.com with ESMTPSA id u2sm7192446ywi.82.2017.10.30.05.35.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Oct 2017 05:35:11 -0700 (PDT) Subject: Re: [PATCH 4/7] GCOV: add -j argument (human readable format). To: marxin , gcc-patches@gcc.gnu.org References: <64ee387ade24b20ee9a6bc2a038abd6664800a61.1509005504.git.mliska@suse.cz> From: Nathan Sidwell Message-ID: Date: Mon, 30 Oct 2017 12:44:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <64ee387ade24b20ee9a6bc2a038abd6664800a61.1509005504.git.mliska@suse.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2017-10/txt/msg02189.txt.bz2 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