unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Kévin Le Gouguec" <kevin.legouguec@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 69555@debbugs.gnu.org, rahguzar@zohomail.eu
Subject: bug#69555: 30.0.50; shr - Preserve indentation when shr-fill-text is nil
Date: Wed, 06 Mar 2024 00:16:53 +0100	[thread overview]
Message-ID: <87jzmgi80q.fsf@gmail.com> (raw)
In-Reply-To: <86edcolav6.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 05 Mar 2024 21:47:09 +0200")

[-- Attachment #1: Type: text/plain, Size: 2090 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Kévin Le Gouguec <kevin.legouguec@gmail.com>
>> Cc: 69555@debbugs.gnu.org,  rahguzar@zohomail.eu
>> Date: Tue, 05 Mar 2024 20:22:52 +0100
>> 
>> Eli Zaretskii <eliz@gnu.org> writes:
>> 
>> > Also, please time the code on some substantially large body of text,
>> > with and without shr-fill-text, and compare that with the current
>> > version.  I think performance is an important aspect of any change in
>> > this area.
>> 
>> Can do; would "(elisp) Profiling" be the starting point?
>
> I think benchmark-run is a better starting point.
>
>> (Also wondering if we have any "standard" or preferred HTML documents or
>> websites to throw at shr.el for benchmarking purposes; if not, I guess
>> I'll peruse <https://en.wikipedia.org/wiki/Special:LongPages> 🤔)
>
> Actually, something with a lot of text in large paragraphs, sometimes
> indented, would be better.  Those Wikipedia pages are basically long
> lists, but there's not much opportunity there to perform filling and
> indentation of large amounts of text, which is what is sought here.
> Here's one possible candidate:
>
>   https://debbugs.gnu.org/Developer.html

Thanks for the pointers.  Attaching the over-engineered scripts I built
from that, which with 1000 REPETITIONS yield:

2024-03-05; 33976ecf244; 30.0.50; master          shr-fill-text=nil  ( 3.013 23  0.313)
2024-03-04; b06916cb218; 30.0.50; shr-blockquote  shr-fill-text=nil  ( 3.121 24  0.328)

2024-03-05; 33976ecf244; 30.0.50; master          shr-fill-text=t    (32.331 65  0.904)
2024-03-04; b06916cb218; 30.0.50; shr-blockquote  shr-fill-text=t    (32.045 65  0.902)

I can bump up REPETITIONS if that would help; sending the scripts &
results as-is before hitting the hay since I figure they might have some
glaring methodology issues, or there is more information I might not
have thought of reporting.

If not, the tentative conclusion would be "shr-fill-text nil gets 4%
slower; shr-fill-text t is none the worse for wear; nil still runs
circles around t"?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: bench.el --]
[-- Type: text/x-emacs-lisp, Size: 1027 bytes --]

;; -*- lexical-binding: t; -*-

(require 'shr)

(defun bench/git (&rest args)
  (car (apply 'process-lines "git" "-C" source-directory args)))

(defun bench/describe-emacs ()
  (let* ((fork-point
          (bench/git
           "merge-base" "--fork-point" "origin/master"
           emacs-repository-version))
         (git-desc
          (bench/git
           "show" "--date=short" "--format=format:%cd; %h" fork-point)))
    (format "%s; %-7s; %s" git-desc emacs-version emacs-repository-branch)))

(let ((dom (with-temp-buffer
             (insert-file-contents "test.html")
             (libxml-parse-html-region)))
      (emacs-desc (bench/describe-emacs)))
  (dolist (val '(nil t))
    (setopt shr-fill-text val)
    (pcase-let ((`(,total-time ,gc-count ,gc-time)
                 (benchmark-run 1000
                   (with-temp-buffer (shr-insert-document dom)))))
      (message
       "%s\tshr-fill-text=%s\t(%6.3f %d %6.3f)"
       (bench/describe-emacs)
       shr-fill-text
       total-time gc-count gc-time))))

[-- Attachment #3: bench.sh --]
[-- Type: application/x-shellscript, Size: 210 bytes --]

  reply	other threads:[~2024-03-05 23:16 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-04 22:02 bug#69555: 30.0.50; shr - Preserve indentation when shr-fill-text is nil Kévin Le Gouguec
2024-03-04 22:08 ` Kévin Le Gouguec
2024-03-05 12:09   ` Eli Zaretskii
2024-03-05 19:22     ` Kévin Le Gouguec
2024-03-05 19:47       ` Eli Zaretskii
2024-03-05 23:16         ` Kévin Le Gouguec [this message]
2024-03-06 11:53           ` Eli Zaretskii
2024-03-06 21:18             ` Kévin Le Gouguec
2024-03-07  6:39               ` Eli Zaretskii
2024-03-06  7:27       ` Rahguzar via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-13 19:55         ` Kévin Le Gouguec
2024-03-13 20:28           ` Rahguzar via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-13 21:41             ` Kévin Le Gouguec
2024-03-14  5:04               ` Eli Zaretskii
2024-03-15  7:10                 ` Kévin Le Gouguec
2024-03-15  8:48                   ` Eli Zaretskii

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87jzmgi80q.fsf@gmail.com \
    --to=kevin.legouguec@gmail.com \
    --cc=69555@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=rahguzar@zohomail.eu \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).