Message ID | 20220714145851.20305-1-raingloom@riseup.net |
---|---|
State | New |
Headers |
Return-Path: <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id BE6A227BBEA; Thu, 14 Jul 2022 16:00:30 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 8028D27BBE9 for <patchwork@mira.cbaines.net>; Thu, 14 Jul 2022 16:00:30 +0100 (BST) Received: from localhost ([::1]:55008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org>) id 1oC0KL-0005Km-6O for patchwork@mira.cbaines.net; Thu, 14 Jul 2022 11:00:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1oC0Ju-0005Jc-Us for guix-patches@gnu.org; Thu, 14 Jul 2022 11:00:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:40833) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1oC0Ju-0007Jq-Kx for guix-patches@gnu.org; Thu, 14 Jul 2022 11:00:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1oC0Ju-0004RC-GF for guix-patches@gnu.org; Thu, 14 Jul 2022 11:00:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#56558] [PATCH] build: Simpler percentage calculation. Resent-From: raingloom <raingloom@riseup.net> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org> Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 14 Jul 2022 15:00:02 +0000 Resent-Message-ID: <handler.56558.B.165781079217008@debbugs.gnu.org> Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 56558 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 56558@debbugs.gnu.org Cc: raingloom <raingloom@riseup.net> X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.165781079217008 (code B ref -1); Thu, 14 Jul 2022 15:00:02 +0000 Received: (at submit) by debbugs.gnu.org; 14 Jul 2022 14:59:52 +0000 Received: from localhost ([127.0.0.1]:38592 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>) id 1oC0Jk-0004QG-1S for submit@debbugs.gnu.org; Thu, 14 Jul 2022 10:59:52 -0400 Received: from lists.gnu.org ([209.51.188.17]:41692) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <raingloom@riseup.net>) id 1oC0Ji-0004Q8-MQ for submit@debbugs.gnu.org; Thu, 14 Jul 2022 10:59:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41028) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <raingloom@riseup.net>) id 1oC0Ji-0004tf-Gt for guix-patches@gnu.org; Thu, 14 Jul 2022 10:59:50 -0400 Received: from mx1.riseup.net ([198.252.153.129]:43340) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <raingloom@riseup.net>) id 1oC0Jg-0007Gw-5a for guix-patches@gnu.org; Thu, 14 Jul 2022 10:59:49 -0400 Received: from fews2.riseup.net (fews2-pn.riseup.net [10.0.1.84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mail.riseup.net", Issuer "R3" (not verified)) by mx1.riseup.net (Postfix) with ESMTPS id 4LkHhf4gmWzDrXX for <guix-patches@gnu.org>; Thu, 14 Jul 2022 14:59:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1657810786; bh=fzL9MmKZHjHsWw4Fn0rJKtE7sxgm70HQBtuIXcqsJrE=; h=From:To:Cc:Subject:Date:From; b=EaVH86Kz2TifawsODaR4BeakiKmnR5xz1Fg8sFY84mCh8RHfhz6W2sECxbpY9Vzoy 6rqNvKNXMEahvKYASZOGZO7fJrcuiTyHvkwDR+h4DhxDjkaLYcw4UrNMbxK/XEFYWO DNCXSW4Y/CX6DNuNdZnrvQZnQBpCLONGbLRRgdUg= X-Riseup-User-ID: 71A3002FE9AA57555A6479D41E0659D74EA13E83245BBAF331A4CB3FBC896A76 Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews2.riseup.net (Postfix) with ESMTPSA id 4LkHhd5JxCz214c; Thu, 14 Jul 2022 14:59:45 +0000 (UTC) From: raingloom <raingloom@riseup.net> Date: Thu, 14 Jul 2022 16:58:51 +0200 Message-Id: <20220714145851.20305-1-raingloom@riseup.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=198.252.153.129; envelope-from=raingloom@riseup.net; helo=mx1.riseup.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: <guix-patches.gnu.org> List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=unsubscribe> List-Archive: <https://lists.gnu.org/archive/html/guix-patches> List-Post: <mailto:guix-patches@gnu.org> List-Help: <mailto:guix-patches-request@gnu.org?subject=help> List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=subscribe> Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> X-getmail-retrieved-from-mailbox: Patches |
Series |
[bug#56558] build: Simpler percentage calculation.
|
|
Commit Message
Csepp
July 14, 2022, 2:58 p.m. UTC
* build-aux/compile-all (%): Simpler calculation that avoids intermediate float. --- build-aux/compile-all.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Am Donnerstag, dem 14.07.2022 um 16:58 +0200 schrieb raingloom: > * build-aux/compile-all (%): Simpler calculation that avoids > intermediate float. > --- > build-aux/compile-all.scm | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/build-aux/compile-all.scm b/build-aux/compile-all.scm > index 9ffbce43ad..6fdbe0dea8 100644 > --- a/build-aux/compile-all.scm > +++ b/build-aux/compile-all.scm > @@ -89,7 +89,7 @@ (define (parallel-job-count*) > > (define (% completed total) > "Return the completion percentage of COMPLETED over TOTAL as an > integer." > - (inexact->exact (round (* 100. (/ completed total))))) > + (quotient (* 100 completed) total)) I am fairly certain that this changes the semantics of %. Try for example (% 23 24). Cheers
Liliana Marie Prikler <liliana.prikler@ist.tugraz.at> writes: > Am Donnerstag, dem 14.07.2022 um 16:58 +0200 schrieb raingloom: >> * build-aux/compile-all (%): Simpler calculation that avoids >> intermediate float. >> --- >> build-aux/compile-all.scm | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/build-aux/compile-all.scm b/build-aux/compile-all.scm >> index 9ffbce43ad..6fdbe0dea8 100644 >> --- a/build-aux/compile-all.scm >> +++ b/build-aux/compile-all.scm >> @@ -89,7 +89,7 @@ (define (parallel-job-count*) >> >> (define (% completed total) >> "Return the completion percentage of COMPLETED over TOTAL as an >> integer." >> - (inexact->exact (round (* 100. (/ completed total))))) >> + (quotient (* 100 completed) total)) > I am fairly certain that this changes the semantics of %. Try for > example (% 23 24). > > Cheers It rounds down instead of up, which, :shrug:. If that's a deal breaker, feel free to close this.
Am Freitag, dem 15.07.2022 um 12:17 +0200 schrieb Csepp: > > Liliana Marie Prikler <liliana.prikler@ist.tugraz.at> writes: > > > Am Donnerstag, dem 14.07.2022 um 16:58 +0200 schrieb raingloom: > > > * build-aux/compile-all (%): Simpler calculation that avoids > > > intermediate float. > > > --- > > > build-aux/compile-all.scm | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/build-aux/compile-all.scm b/build-aux/compile- > > > all.scm > > > index 9ffbce43ad..6fdbe0dea8 100644 > > > --- a/build-aux/compile-all.scm > > > +++ b/build-aux/compile-all.scm > > > @@ -89,7 +89,7 @@ (define (parallel-job-count*) > > > > > > (define (% completed total) > > > "Return the completion percentage of COMPLETED over TOTAL as > > > an > > > integer." > > > - (inexact->exact (round (* 100. (/ completed total))))) > > > + (quotient (* 100 completed) total)) > > I am fairly certain that this changes the semantics of %. Try for > > example (% 23 24). > > > > Cheers > > It rounds down instead of up, which, :shrug:. > If that's a deal breaker, feel free to close this. It's not simply "rounding up", you need to round towards the nearest, which can be done with just quotient and remainder, but is probably more complicated than the float solution.
Liliana Marie Prikler <liliana.prikler@ist.tugraz.at> writes: > Am Freitag, dem 15.07.2022 um 12:17 +0200 schrieb Csepp: >> >> Liliana Marie Prikler <liliana.prikler@ist.tugraz.at> writes: >> >> > Am Donnerstag, dem 14.07.2022 um 16:58 +0200 schrieb raingloom: >> > > * build-aux/compile-all (%): Simpler calculation that avoids >> > > intermediate float. >> > > --- >> > > build-aux/compile-all.scm | 2 +- >> > > 1 file changed, 1 insertion(+), 1 deletion(-) >> > > >> > > diff --git a/build-aux/compile-all.scm b/build-aux/compile- >> > > all.scm >> > > index 9ffbce43ad..6fdbe0dea8 100644 >> > > --- a/build-aux/compile-all.scm >> > > +++ b/build-aux/compile-all.scm >> > > @@ -89,7 +89,7 @@ (define (parallel-job-count*) >> > > >> > > (define (% completed total) >> > > "Return the completion percentage of COMPLETED over TOTAL as >> > > an >> > > integer." >> > > - (inexact->exact (round (* 100. (/ completed total))))) >> > > + (quotient (* 100 completed) total)) >> > I am fairly certain that this changes the semantics of %. Try for >> > example (% 23 24). >> > >> > Cheers >> >> It rounds down instead of up, which, :shrug:. >> If that's a deal breaker, feel free to close this. > It's not simply "rounding up", you need to round towards the nearest, > which can be done with just quotient and remainder, but is probably > more complicated than the float solution. Yeah, I meant it rounds up in that case. Since it's only used for indicating progress to the user, being off by 1% is not something I'd worry about, but whatevs, I guess we can leave it as is.
diff --git a/build-aux/compile-all.scm b/build-aux/compile-all.scm index 9ffbce43ad..6fdbe0dea8 100644 --- a/build-aux/compile-all.scm +++ b/build-aux/compile-all.scm @@ -89,7 +89,7 @@ (define (parallel-job-count*) (define (% completed total) "Return the completion percentage of COMPLETED over TOTAL as an integer." - (inexact->exact (round (* 100. (/ completed total))))) + (quotient (* 100 completed) total)) ;; Install a SIGINT handler to give unwind handlers in 'compile-file' an ;; opportunity to run upon SIGINT and to remove temporary output files.