From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: JD Smith Newsgroups: gmane.emacs.bugs Subject: bug#71572: [PATCH] seconds-to-string-approximate Date: Sat, 30 Nov 2024 13:58:52 -0500 Message-ID: References: <86r0cpicwt.fsf@gnu.org> <86msmxafog.fsf@gnu.org> <3530cd89-b5a2-4b25-95bf-1896c8ee4aef@cs.ucla.edu> <8CC4B1BB-B56A-4C3E-8B51-0E2D5B65C296@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_F139D8F7-18E6-4A7B-9A53-E9A903252D7F" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33797"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Adam Porter , Eli Zaretskii , jonas@bernoul.li, Paul Eggert To: 71572@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 30 20:01:18 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tHSiT-0008cu-Ci for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 30 Nov 2024 20:01:17 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tHSiF-0000wH-OC; Sat, 30 Nov 2024 14:01:03 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tHSiF-0000w9-1E for bug-gnu-emacs@gnu.org; Sat, 30 Nov 2024 14:01:03 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tHSiE-0001n1-Ou for bug-gnu-emacs@gnu.org; Sat, 30 Nov 2024 14:01:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:Date:Mime-Version:From:To:Subject; bh=Zup4CtLLac8guPL1CNFIhnRg7f7OQcUg0RXx8Wiq8Lo=; b=SHaNYK2ZO1RzURQFfPKLwOZvH9SwJFHoHyJ36dHPBDxE0wFUgWsjeBe6GbEFEnvFSk/UQEGFnnx+fhzIMOyqefTMZtd9y/G13nP/g/bhjqOc9nB+ghvf6NISO8J6aELSuq/IM/wL9CbcyztWkOi+w1RuKrV0RGoua4dbv/I1vIN6i+Z+fcCLdbruSuvMNGUnH6Jjs26qMaoIoZ9+CC+JNh9qEEfA30ZSyE7D0E7ykZqrCVKgJixYyRjcvenXv5X/nZeEuOA6miVq3RVRPVn2gNkXcEUIhKvod7+L84H2QaKb/6C9iejmDQFFxMaCyXEhSnyM69VuRkPc6A7bZLMPkw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tHSiE-0002pa-JF for bug-gnu-emacs@gnu.org; Sat, 30 Nov 2024 14:01:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: JD Smith Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 30 Nov 2024 19:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71572 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 71572-submit@debbugs.gnu.org id=B71572.173299321310793 (code B ref 71572); Sat, 30 Nov 2024 19:01:02 +0000 Original-Received: (at 71572) by debbugs.gnu.org; 30 Nov 2024 19:00:13 +0000 Original-Received: from localhost ([127.0.0.1]:49076 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tHShQ-0002nz-Ow for submit@debbugs.gnu.org; Sat, 30 Nov 2024 14:00:13 -0500 Original-Received: from mail-il1-f172.google.com ([209.85.166.172]:48459) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tHShO-0002hq-He for 71572@debbugs.gnu.org; Sat, 30 Nov 2024 14:00:11 -0500 Original-Received: by mail-il1-f172.google.com with SMTP id e9e14a558f8ab-3a78c242d50so10374945ab.1 for <71572@debbugs.gnu.org>; Sat, 30 Nov 2024 11:00:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732993144; x=1733597944; darn=debbugs.gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=Zup4CtLLac8guPL1CNFIhnRg7f7OQcUg0RXx8Wiq8Lo=; b=aQpHNKD59b/tpJ7ULJRo7rE1Sqlzi0dhjWQTwWT37Z2ojh41VvKvUMRzfQQipW4rtI bUK0FGP2tgDJjesM99j3sPxuTro21VEKUoQkigJPi0SQfDgjBprrW5wLpCEQyfQo4Uc4 gmViDwx9QdPiAoJKoJM7vCSf/opo4kc+++tuF6R7OyY8NoQ83oakQGnbI0E2Mx1ByJw3 7alrCtgyvl3xbB0TilMftGOfM5tmWCUVjKcexKEjw3LYHl5fKjuBmpoeSLw3IHEO0Nly AL1mG3UPpFd32gxdWvIu8ewN2nfZUqsXn4JE6Q/tteY09fn5v2TsdsTr3z5ghX2WA5kC tOfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732993144; x=1733597944; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Zup4CtLLac8guPL1CNFIhnRg7f7OQcUg0RXx8Wiq8Lo=; b=nDGz/PtM7yRYo1Y/zAYYHUlUsuequSDJkdIvnJ/BL4NoY2OAiUzcL2RaRSa1oC9bj1 ioWH//SsiDYTowpVzu3GoW0VawqQ+SFiGSf1IqdKP2ZGE6PKB1vHpqG+WdkypYrx8oYL G8hadYypmGHsA4LIlkJeBqyNC4V3gDBA/In0aPvOxJQkCHODTqMiL9r8aYT6TKb61sTA 6k5/few1uc1x0njfsW8wZ1ikicieYon9jBM/7uape+q/tE0k5tC/Co9tfZbtok92OOUU gqDMsEUSgbnMrkj0CHudXzBxMoK6IKN58m31Tft4JaZWn1pvi8Y0rjzGMuO2Mch5PHRb qBLw== X-Gm-Message-State: AOJu0Yzki/TyyCRXN1GwCfjzxe+ZZbKc9dJNnjvcCrQXJeCMGV5eW+p8 kvPAv6GnNAsvlDhZfh8Nfd1MibK/35noRsPafkPqTuEH7NKeiqbVyRuLGw== X-Gm-Gg: ASbGncsBozaNDmN4m69kWv34z05p0q3f8bOyWZdgcW8KIEfFjrtIIZiLXsdKvjDyuc8 qI9BUQB+CkyBvOExqM/Ny0n4lB+CURwtS6l11o2jCh/nJjYhqgoPdZuFq7Vh0vI6nDlFhN55U+8 LzdjJB1E1X26Au14E+XLrCuHPhbr6uiahiILDpOgh31utATue7cP5rMZSzyFJK1xvRHK8lnKFDA CR7tW2Rw3t9Gkau3X17VR8Ngoa99FxWbPcSuaUX5tYd9maRiWv73TZbmyWORJtaMPFcQqVgkBat edBsfZaaaIqHnS9H0jmCXA== X-Google-Smtp-Source: AGHT+IG6cM9u8tcTNYJsPNMdpziKfQdoWVJnFZYyBRyIc61/ke2WicMMNNsIeStqPqDKYdbHWH6rlg== X-Received: by 2002:a05:6e02:2144:b0:3a7:7124:bd2c with SMTP id e9e14a558f8ab-3a7c55d9bddmr191814635ab.19.1732993144446; Sat, 30 Nov 2024 10:59:04 -0800 (PST) Original-Received: from smtpclient.apple (cm-24-53-185-196.buckeyecom.net. [24.53.185.196]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3a7dfa49fbbsm7090265ab.21.2024.11.30.10.59.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Nov 2024 10:59:03 -0800 (PST) In-Reply-To: <8CC4B1BB-B56A-4C3E-8B51-0E2D5B65C296@gmail.com> X-Mailer: Apple Mail (2.3774.600.62) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:296199 Archived-At: --Apple-Mail=_F139D8F7-18E6-4A7B-9A53-E9A903252D7F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 I was recently reminded of the need for a more capable = seconds-to-string. =20 Anyone have any additional comments on this proposed patch? If not, I'd = suggest someone with access merges. JD > On Jul 11, 2024, at 5:01=E2=80=AFPM, JD Smith = wrote: >=20 >=20 >=20 >> On Jul 6, 2024, at 5:09=E2=80=AFPM, Paul Eggert = wrote: >>=20 >> On 7/6/24 21:29, JD Smith wrote: >>> do we universally avoid unicode in core files? >>=20 >> Not in comments, but even today it's wise to be cautious about = generating user-visible Unicode characters like "=C2=BD" when there's a = simple ASCII substitute like ".5". Plus, why stop with =C2=BD? Why not = also do =C2=BC and =C2=BE? >>=20 >> It might be better to have an optional precision argument, defaulting = to 0, specifying the number of digits of precision after the decimal = point. Or something like that. >=20 > Thanks for the feedback. Attached find an updated patch: >=20 > - HALF is dropped. > - PRECISION can now be specified as a whole-number of digits or a = float <1.0 (e.g. 0.5) > - NEWS and doc entries. >=20 > Users who want =C2=BD can always use precision=3D0.5 and edit the = string after the fact. >=20 > Another attached file includes commands to produce and display a = simple benchmark, as well as the example output (below). =20 >=20 > I see about a 10x performance difference between the standard = seconds-to-string and the "bells and whistles" readable version. It's = still <35=C2=B5s per delay for me, so formatting thousands of strings at = once should be no problem. Happy to take performance improvement ideas. >=20 > Current example: >=20 > Delay (s) s2s s2s-r s2s-ra s2s-ra1 s2s-rah = s2s-e s2s-ea s2s-ea1 s2s-ea3 s2s-eah > 0.000 0s 0 seconds 0s 0s 0s = 0 seconds 0s 0s 0s 0s > 0.450 450.00ms 0 seconds 0s 0.4s 0.5s = 0 seconds 0s 0.4s 0.450s 0.5s > 1.035 1.03s 1 second 1s 1s 1s = 1 second 1s 1s 1.035s 1s > 2.380 2.38s 2 seconds 2s 2.4s 2.5s = 2 seconds 2s 2.4s 2.380s 2.5s > 5.475 5.48s 5 seconds 5s 5.5s 5.5s = 5 seconds 5s 5.5s 5.475s 5.5s > 12.593 12.59s 13 seconds 13s 12.6s 12.5s = 13 seconds 13s 12.6s 12.593s 12.5s > 28.964 28.96s 29 seconds 29s 29s 29s = 29 seconds 29s 29s 28.964s 29s > 66.616 66.62s 1 minute 1m 1.1m 1m 1 = minute 7 seconds 1m 7s 1m 6.6s 1m 6.616s 1m 6.5s > 153.217 2.55m 3 minutes 3m 2.6m 2.5m 2 = minutes 33 seconds 2m 33s 2m 33.2s 2m 33.217s 2m 33s > 352.399 5.87m 6 minutes 6m 5.9m 6m 5 = minutes 52 seconds 5m 52s 5m 52.4s 5m 52.399s 5m 52.5s > 810.519 13.51m 14 minutes 14m 13.5m 13.5m 13 = minutes 31 seconds 13m 31s 13m 30.5s 13m 30.519s 13m 30.5s > 1864.193 31.07m 31 minutes 31m 31.1m 31m 31 = minutes 4 seconds 31m 4s 31m 4.2s 31m 4.193s 31m 4s > 4287.644 71.46m 1 hour 1h 1.2h 1h 1 = hour 11 minutes 1h 11m 1h 11.5m 1h 11.461m 1h 11.5m > 9861.581 2.74h 3 hours 3h 2.7h 2.5h 2 = hours 44 minutes 2h 44m 2h 44.4m 2h 44.360m 2h 44.5m > 22681.636 6.30h 6 hours 6h 6.3h 6.5h 6 = hours 18 minutes 6h 18m 6h 18m 6h 18.027m 6h 18m > 52167.763 14.49h 14 hours 14h 14.5h 14.5h 14 = hours 29 minutes 14h 29m 14h 29.5m 14h 29.463m 14h 29.5m > 119985.856 1.39d 1 day 1d 1.4d 1.5d = 1 day 9 hours 1d 9h 1d 9.3h 1d 9.329h 1d 9.5h > 275967.469 3.19d 3 days 3d 3.2d 3d = 3 days 5 hours 3d 5h 3d 4.7h 3d 4.658h 3d 4.5h > 634725.178 7.35d 1 week 1w 1w 1w = 1 week 1w 1w 0.3d 1w 0.346d 1w 0.5d > 1459867.909 16.90d 2 weeks 2w 2.4w 2.5w = 2 weeks 3 days 2w 3d 2w 2.9d 2w 2.897d 2w 3d > 3357696.192 38.86d 1 month 1M 1.3M 1.5M = 1 month 1 week 1M 1w 1M 1.2w 1M 1.204w 1M 1w > 7722701.241 89.38d 3 months 3M 2.9M 3M = 2 months 4 weeks 2M 4w 2M 4.1w 2M 4.073w 2M 4w > 17762212.854 205.58d 7 months 7M 6.8M 7M = 6 months 3 weeks 6M 3w 6M 3.3w 6M 3.280w 6M 3.5w > 40853089.565 1.29y 1 year 1Y 1.3Y 1.5Y = 1 year 4 months 1Y 4M 1Y 3.5M 1Y 3.535M 1Y 3.5M > 93962105.999 2.98y 3 years 3Y 3Y 3Y 2 = years 12 months 2Y 12M 2Y 11.7M 2Y 11.730M 2Y 11.5M > 216112843.798 6.85y 7 years 7Y 6.8Y 7Y 6 = years 10 months 6Y 10M 6Y 10.2M 6Y 10.180M 6Y 10M > 497059540.736 15.75y 16 years 16Y 15.8Y 16Y = 15 years 9 months 15Y 9M 15Y 9M 15Y 9.014M 15Y 9M > 1143236943.694 36.23y 36 years 36Y 36.2Y 36Y = 36 years 3 months 36Y 3M 36Y 2.7M 36Y 2.733M 36Y 2.5M >=20 > > <0001-seconds-to-string-new-optional-arguments-for-readabl.patch> >=20 >=20 --Apple-Mail=_F139D8F7-18E6-4A7B-9A53-E9A903252D7F Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 I was recently = reminded of the need for a more capable seconds-to-string. =  

Anyone have any additional comments on this = proposed patch?  If not, I'd suggest someone with access = merges.

JD

On Jul 11, 2024, at 5:01=E2=80=AFPM, JD Smith = <jdtsmith@gmail.com> wrote:



On Jul 6, 2024, at 5:09=E2=80=AFPM, Paul Eggert = <eggert@cs.ucla.edu> wrote:

On 7/6/24 21:29, JD Smith = wrote:
do we universally avoid unicode in = core files?

Not in comments, but even today it's = wise to be cautious about generating user-visible Unicode characters = like "=C2=BD" when there's a simple ASCII substitute like ".5". Plus, = why stop with =C2=BD? Why not also do =C2=BC and =C2=BE?

It might = be better to have an optional precision argument, defaulting to 0, = specifying the number of digits of precision after the decimal point. Or = something like that.

Thanks = for the feedback.  Attached find an updated = patch:

- HALF is dropped.
- PRECISION = can now be specified as a whole-number of digits or a float <1.0 = (e.g. 0.5)
- NEWS and doc = entries.

Users who want =C2=BD can always use = precision=3D0.5 and edit the string after the = fact.

Another attached file includes commands = to produce and display a simple benchmark, as well as the example output = (below).  

I see about a 10x performance = difference between the standard seconds-to-string and the "bells and = whistles" readable version.  It's still <35=C2=B5s per delay for = me, so formatting thousands of strings at once should be no problem. =  Happy to take performance improvement = ideas.

Current example:

     Delay (s)        s2s =       s2s-r  s2s-ra  s2s-ra1  s2s-rah =                  s2s-e =   s2s-ea    s2s-ea1      s2s-ea3   =  s2s-eah
    =      0.000         0s   0 = seconds      0s       0s     =   0s              0 seconds =       0s         0s     =       0s         = 0s
      =    0.450   450.00ms   0 seconds     =  0s     0.4s     0.5s       =        0 seconds       0s   =     0.4s       0.450s       = 0.5s
      =    1.035      1.03s    1 second =      1s       1s       1s =               1 second     =   1s         1s       1.035s =         1s
         2.380      2.38s =   2 seconds      2s     2.4s     = 2.5s              2 seconds   =     2s       2.4s       2.380s =       2.5s
         5.475      5.48s =   5 seconds      5s     5.5s     = 5.5s              5 seconds   =     5s       5.5s       5.475s =       5.5s
        12.593     12.59s  13 = seconds     13s    12.6s    12.5s   =           13 seconds      13s =      12.6s      12.593s     =  12.5s
    =     28.964     28.96s  29 seconds     = 29s      29s      29s       =       29 seconds      29s     =    29s      28.964s       =  29s
    =     66.616     66.62s    1 minute   =    1m     1.1m       1m     = 1 minute 7 seconds    1m 7s    1m 6.6s   =  1m 6.616s    1m 6.5s
       153.217      2.55m =   3 minutes      3m     2.6m     = 2.5m   2 minutes 33 seconds   2m 33s   2m 33.2s   2m = 33.217s     2m 33s
       352.399      5.87m =   6 minutes      6m     5.9m     =   6m   5 minutes 52 seconds   5m 52s   5m 52.4s =   5m 52.399s   5m 52.5s
       810.519     13.51m  14 = minutes     14m    13.5m    13.5m  13 = minutes 31 seconds  13m 31s  13m 30.5s  13m 30.519s =  13m 30.5s
  =     1864.193     31.07m  31 minutes   =   31m    31.1m      31m   31 minutes = 4 seconds   31m 4s   31m 4.2s   31m 4.193s     = 31m 4s
      = 4287.644     71.46m      1 hour     =  1h     1.2h       1h     =  1 hour 11 minutes   1h 11m   1h 11.5m   1h 11.461m =   1h 11.5m
  =     9861.581      2.74h     3 hours =      3h     2.7h     2.5h   =   2 hours 44 minutes   2h 44m   2h 44.4m   2h = 44.360m   2h 44.5m
     22681.636      6.30h   =   6 hours      6h     6.3h     = 6.5h     6 hours 18 minutes   6h 18m     6h 18m =   6h 18.027m     6h 18m
     52167.763     14.49h =    14 hours     14h    14.5h   =  14.5h    14 hours 29 minutes  14h 29m  14h = 29.5m  14h 29.463m  14h 29.5m
    119985.856      1.39d =       1 day      1d     1.4d =     1.5d          1 day 9 hours =    1d 9h    1d 9.3h    1d 9.329h   =  1d 9.5h
    = 275967.469      3.19d      3 days   =    3d     3.2d       3d     =     3 days 5 hours    3d 5h    3d 4.7h =    3d 4.658h    3d 4.5h
    634725.178      7.35d =      1 week      1w       = 1w       1w             =     1 week       1w    1w 0.3d   =  1w 0.346d    1w 0.5d
   1459867.909     16.90d     2 = weeks      2w     2.4w     2.5w =         2 weeks 3 days    2w 3d   =  2w 2.9d    2w 2.897d      2w = 3d
   3357696.192 =     38.86d     1 month      1M   =   1.3M     1.5M         1 month 1 = week    1M 1w    1M 1.2w    1M 1.204w =      1M 1w
   7722701.241     89.38d    3 = months      3M     2.9M       3M =       2 months 4 weeks    2M 4w    2M = 4.1w    2M 4.073w      2M = 4w
  17762212.854 =    205.58d    7 months      7M   =   6.8M       7M       6 months 3 = weeks    6M 3w    6M 3.3w    6M 3.280w =    6M 3.5w
  = 40853089.565      1.29y      1 year   =    1Y     1.3Y     1.5Y     =    1 year 4 months    1Y 4M    1Y 3.5M =    1Y 3.535M    1Y 3.5M
  93962105.999      2.98y =     3 years      3Y       3Y =       3Y      2 years 12 months   2Y = 12M   2Y 11.7M   2Y 11.730M   2Y = 11.5M
 216112843.798 =      6.85y     7 years      7Y =     6.8Y       7Y      6 years = 10 months   6Y 10M   6Y 10.2M   6Y 10.180M     = 6Y 10M
 497059540.736 =     15.75y    16 years     16Y   =  15.8Y      16Y      15 years 9 = months   15Y 9M     15Y 9M   15Y 9.014M   =   15Y 9M
1143236943.694 =     36.23y    36 years     36Y   =  36.2Y      36Y      36 years 3 = months   36Y 3M   36Y 2.7M   36Y 2.733M   36Y = 2.5M

<s2s_test.el>=
<0001-seconds-to-string= -new-optional-arguments-for-readabl.patch>



= --Apple-Mail=_F139D8F7-18E6-4A7B-9A53-E9A903252D7F--