From: Theodor Thornhill <theo@thornhill.no>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca
Subject: Re: CC Mode -> Tree sitter challenge
Date: Sat, 05 Nov 2022 14:12:14 +0100 [thread overview]
Message-ID: <87mt951r69.fsf@thornhill.no> (raw)
In-Reply-To: <83eduh4vcf.fsf@gnu.org>
Hi Eli,
[...]
>> - TypeScript (left out, as it is in tree-sitter branch already)
>
> Thanks.
My pleasure.
>> 2. I've focused mostly on indentation and font locking. Indentation is
>> using xdisp code style and the gnu style in general.
>
> We should ideally support all the indentation styles supported by CC
> Mode.
>
Yes, I'll try to be as comprehensive as possible.
>> When scrolling through xdisp with this variant of C support it is
>> noticeably faster on my system. However, I'd like some guidance on how
>> to provide some benchmarks to prove my guess.
>
> We usually use something like the below:
Thanks, I used them, see results below.
> The instructions are: visit xdisp.c and immediately invoke one of
> these two functions; then record the time it took to scroll through
> the entire file. Compare to CC Mode.
>
> I think we also want to see the above modified to make some change to
> the buffer once in a while. For example, once in 100 lines insert a
> quote ", or a /* followed by */ after several lines, and see how that
> affects the scroll times with both modes.
>
>> Loading said file and immediately going to EOB is instant, but in CC
>> Mode takes a little less than a second.
>
> Timing this with benchmark-run and presenting the numbers is also
> interesting.
So this is the code with results thus far. It is immediately apparent
how much faster this is, IMO. Every test is run from a fresh `emacs
-Q`. I just eval the files, enable the modes and run the tests.
What do you think? Is there anything clearly wrong with the benchmarks?
In many of the cases tree-sitter is an order of magnitude faster.
```
(defun scroll-up-benchmark ()
(interactive)
(let ((oldgc gcs-done)
(oldtime (float-time)))
(condition-case nil (while t (scroll-up) (redisplay))
(error (message "GCs: %d Elapsed time: %f seconds"
(- gcs-done oldgc) (- (float-time) oldtime))))))
(defun scroll-up-by-40-benchmark ()
(interactive)
(let ((oldgc gcs-done)
(oldtime (float-time)))
(condition-case nil (while t (scroll-up 40) (redisplay))
(error (message "GCs: %d Elapsed time: %f seconds"
(- gcs-done oldgc) (- (float-time) oldtime))))))
(defun scroll-up-insert-quote-benchmark ()
(interactive)
(let ((oldgc gcs-done)
(oldtime (float-time)))
(condition-case nil
(while t
(scroll-up 50)
(when (zerop (mod (1- (line-number-at-pos)) 100))
(insert "\""))
(redisplay))
(error (message "GCs: %d Elapsed time: %f seconds"
(- gcs-done oldgc) (- (float-time) oldtime))))))
(defun xdisp-eob-benchmark ()
(benchmark-run 100
(progn
(with-current-buffer (find-file "~/src/emacs/src/xdisp.c")
(end-of-buffer))
(kill-buffer "xdisp.c"))))
;; C-MODE
;; scroll-up-benchmark
;; 1: GCs: 402 Elapsed time: 17.499269 seconds
;; 2: GCs: 415 Elapsed time: 17.789382 seconds
;; scroll-up-by-40-benchmark
;; 1: GCs: 420 Elapsed time: 19.183639 seconds
;; 2: GCs: 420 Elapsed time: 19.377480 seconds
;; xdisp-eob-benchmark 100
;; 1: (40.992420494 1708 16.708356162)
;; 2: (40.630712261 1711 16.361947911999998)
;; xdisp-eob-benchmark 1
;; 1: (0.482883063 21 0.19676500600000002)
;; 2: (0.478595514 21 0.19573110300000002)
;; scroll-up-insert-quote-benchmark
;; 1: GCs: 558 Elapsed time: 41.747822 seconds
;; 2: GCs: 557 Elapsed time: 41.976805 seconds
;; C-TS-MODE
;; scroll-up-benchmark
;; 1: GCs: 21 Elapsed time: 6.997570 seconds
;; 2: GCs: 27 Elapsed time: 7.239952 seconds
;; scroll-up-by-40-benchmark
;; 1: GCs: 30 Elapsed time: 8.869021 seconds
;; 2: GCs: 29 Elapsed time: 9.076617 seconds
;; xdisp-eob-benchmark 100
;; 1: (15.083917789 20 1.1350005760000001)
;; 2: (15.213992551999999 21 1.121564519)
;; xdisp-eob-benchmark 1
;; 1: (0.19189711499999998 1 0.011011572999999997)
;; 2: (0.185749092 1 0.011173242)
;; scroll-up-insert-quote-benchmark
;; 1: GCs: 29 Elapsed time: 15.450495 seconds
;; 2: GCs: 29 Elapsed time: 12.168593 seconds
```
Theo
next prev parent reply other threads:[~2022-11-05 13:12 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-04 20:34 CC Mode -> Tree sitter challenge Theodor Thornhill
2022-11-04 20:36 ` Theodor Thornhill
2022-11-04 20:38 ` Stefan Monnier
2022-11-04 20:44 ` Theodor Thornhill
2022-11-04 23:10 ` Yuan Fu
2022-11-05 7:56 ` Theodor Thornhill
2022-11-06 1:01 ` Yuan Fu
2022-11-06 5:54 ` Theodor Thornhill
2022-11-05 9:13 ` Eli Zaretskii
2022-11-05 13:12 ` Theodor Thornhill [this message]
2022-11-05 13:31 ` Eli Zaretskii
2022-11-05 13:42 ` Theodor Thornhill
2022-11-05 14:37 ` Theodor Thornhill
2022-11-05 14:55 ` Eli Zaretskii
2022-11-05 15:06 ` Theodor Thornhill
2022-11-05 15:27 ` Theodor Thornhill
2022-11-05 16:38 ` Theodor Thornhill
2022-11-05 16:43 ` Eli Zaretskii
2022-11-06 1:13 ` Yuan Fu
2022-11-06 6:04 ` Theodor Thornhill
2022-11-07 0:11 ` Yuan Fu
2022-11-07 8:05 ` Theodor Thornhill
2022-11-05 14:34 ` Stefan Monnier
2022-11-05 14:46 ` Theodor Thornhill
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mt951r69.fsf@thornhill.no \
--to=theo@thornhill.no \
--cc=casouri@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.