emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CC Mode -> Tree sitter challenge


From: Eli Zaretskii
Subject: Re: CC Mode -> Tree sitter challenge
Date: Sat, 05 Nov 2022 11:13:52 +0200

> From: Theodor Thornhill <theo@thornhill.no>
> Cc: Eli Zaretskii <eliz@gnu.org>, casouri@gmail.com, Stefan Monnier
>  <monnier@iro.umontreal.ca>
> Date: Fri, 04 Nov 2022 21:34:18 +0100
> 
> 
> Hi Eli and others!
> 
> So you challenged me to add some more modes that are supported in CC
> Mode, but not using CC Mode.  I finally got some free hours, so here's
> my first follow-up to your "show me the code".
> 
> In this repo[0] you will find support for the following modes:
> 
> - javascript  (this is already in tree-sitter branch - but adding
>   without cc mode here)
> - c
> - c++
> - java
> - css
> - JSON
> - TypeScript (left out, as it is in tree-sitter branch already)

Thanks.

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

> 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:

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

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]