From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#71573: Related functions from ts.el Date: Sat, 22 Jun 2024 03:55:41 -0700 Message-ID: References: <0f564d69-2d04-49b9-935d-15ed8741c7ba@alphapapa.net> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29265"; mail-complaints-to="usenet@ciao.gmane.io" To: Adam Porter , 71573@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 22 12:57:21 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 1sKyQq-0007KY-V8 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 22 Jun 2024 12:57:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKyQb-0007M2-8h; Sat, 22 Jun 2024 06:57:05 -0400 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 1sKyQa-0007JH-17 for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2024 06:57:04 -0400 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 1sKyQZ-0004Oa-PE for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2024 06:57:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sKyQY-0003f8-DS for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2024 06:57:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 22 Jun 2024 10:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71573 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 71573-submit@debbugs.gnu.org id=B71573.171905381314060 (code B ref 71573); Sat, 22 Jun 2024 10:57:02 +0000 Original-Received: (at 71573) by debbugs.gnu.org; 22 Jun 2024 10:56:53 +0000 Original-Received: from localhost ([127.0.0.1]:44526 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sKyQP-0003ei-Dz for submit@debbugs.gnu.org; Sat, 22 Jun 2024 06:56:53 -0400 Original-Received: from mail-lj1-f171.google.com ([209.85.208.171]:44060) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sKyQK-0003eQ-4J for 71573@debbugs.gnu.org; Sat, 22 Jun 2024 06:56:51 -0400 Original-Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2ebeefb9a7fso31992931fa.0 for <71573@debbugs.gnu.org>; Sat, 22 Jun 2024 03:56:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719053742; x=1719658542; darn=debbugs.gnu.org; h=to:subject:message-id:date:mime-version:references:in-reply-to:from :from:to:cc:subject:date:message-id:reply-to; bh=m8NmohMeAaELX/SnI17bqtjo8SOJC+LEtR98VEJPITc=; b=FNdgzlNJIjw7M3YGo1XWSdpmfthkEyE1NsXzU080Mb7k+fXJqqcyIjwpcVUXX0geT8 X5kCEGFAbgCMbUAFU5MoWd+X5fp8BBMXh+2JVVeiVcQNWNqZ6hj56MXuCtjBZyBGGCB4 DnavGsUIPqLAzD8O8VlB8vqOBugN8yu4X979VqkNgCW+5fGzAw5O9Mwx6eU3NeMfY+fA PspgdgGXyHPwIAtXway6UIUlmiRinEWefUhsZ1YTiaZ3I/yefAHHQkJXy+XEKcKROy2X 2dM7seeCoVm3IZXOqQVHPrdPQo9JgsejUTTE2CgCAG9P4HilMZlj+7HjHkqE9QZH1J4a UUmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719053742; x=1719658542; h=to:subject:message-id:date:mime-version:references:in-reply-to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=m8NmohMeAaELX/SnI17bqtjo8SOJC+LEtR98VEJPITc=; b=WfzNRO/mgMjNa4fkeJQqwuYuPlPYLF5cR/5WNkjDGEBvIeS9ibILO4I5MlzRqh2Ubf rxN/03IdQ7pmX3/YAazMfxvjFKBjObxjtu4zeqpE3NPlIuDgF6vBTuycNMJm2b/t+xbP Ed4FD/04+1TFxRfQ0/8QJF1m5fTk6JJSsL3i1RfmTstxGVv9YN5hzsD1890t27gGlF1s /E0pMfTQp7lwtPQbUKqSrLouT5PieRt+oKteTkVA3iu1FVua85yY6uLHnXqm1V8WJBeT AfTDRqH7sntRmTVjaZvva9h6yGnO4P0mizHASMadVdeI81TOSJnKBRk2LrGab1fL7IXk ipqg== X-Forwarded-Encrypted: i=1; AJvYcCVHugRJXtd/yuDMJq9D2IzAE699yR25XzDYPmA7BivQCCCXVQ1yCw7gQ7whDP2y2HVtfgAib7iMFK6TN+ZrQJQaMXcH6Lg= X-Gm-Message-State: AOJu0YzDb9tTrsOsDoStZdVkwZw/8bgY5l/iC+d550OHZArCfUUUvWeX PKi2uT4Frk8YQGIWLWC1b9zb9URk6IaglT7Ww4FLYqkXJORs5I03rqGNIPsh5RHEAaIzOGTiM2V fd8XdWwlue8Iyl/dDm3D808hBrQHzX+LK X-Google-Smtp-Source: AGHT+IHKvyF/sHHSSLnJ9jOi7R8/uPwKjxjbVZn8eWNOck4GG0p1mBCzojJE+ag11ExWYboRqU4HR30axPhwqYutmZk= X-Received: by 2002:a2e:8717:0:b0:2ec:4f0c:3705 with SMTP id 38308e7fff4ca-2ec579ffb4dmr4404241fa.46.1719053741904; Sat, 22 Jun 2024 03:55:41 -0700 (PDT) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sat, 22 Jun 2024 03:55:41 -0700 In-Reply-To: <0f564d69-2d04-49b9-935d-15ed8741c7ba@alphapapa.net> 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:287690 Archived-At: Adam Porter writes: > ;; See also the built-in function `format-seconds', which I seem to have > ;; overlooked before writing this. However, a quick benchmark, run > ;; 100,000 times, shows that, when controllable formatting is not needed, > ;; `ts-human-format-duration' is much faster and generates less garbage: > > ;; | Form | x faster than next | Total runtime | # > of GCs | Total GC runtime | > ;; > |--------------------------+--------------------+---------------+----------+------------------| > ;; | ts-human-format-duration | 5.82 | 0.832945 | > 3 | 0.574929 | > ;; | format-seconds | slowest | 4.848253 | > 17 | 3.288799 | Is this used a lot in hot loops? IOW, is it worth optimizing? If yes, how about adding something like what you have as an optimization to `format-seconds` for when the format is very simple? Would that remove the need for `ts-human-format-duration'?