Subject: Re: When font size is temporarily increased Emacs is slow

From: Mark Karpov <[email-masked]>
Date: Sun, 27 Sep 2015 17:02:12 +0600

Here I describe my experiment and its outcome.

Setting
=======

To measure how long it takes to scroll a long buffer from beginning to
end with ‘next-line’ command the following code was evaluated:

  (defmacro with-timer (title &rest forms)
    "Run the given FORMS, counting the elapsed time.
  A message including the given TITLE and the corresponding elapsed
  time is displayed."
    (declare (indent 1))
    (let ((nowvar (make-symbol "now"))
          (body   `(progn ,@forms)))
      `(let ((,nowvar (current-time)))
         (message "%s..." ,title)
         (prog1 ,body
           (let ((elapsed
                  (float-time (time-subtract (current-time) ,nowvar))))
             (message "%s... done (%.3fs)" ,title elapsed))))))
  
  (defun next-line-racer ()
    "Scroll till end of buffer with `next-line' and measure how long it takes.
  
  To make it realistic `next-line' is called interactively."
    (interactive)
    (with-timer 
        (while (not (eobp))
          (call-interactively #'next-line))))

The file used:

https://github.com/Fuco1/smartparens/blob/master/smartparens.el

which is 7992 lines long.

The Experiment
==============

The file is opened and cursor is at the beginning of the file. Font size
is either altered with ‘C-x C-=’ (increased, denoted in results as +1)
or ‘C-x C--’ (decreased, denoted in results as -1) or not altered at
all. No adjustments to compensate number of visible lines were performed
in this experiment because I think difference wouldn't be noticeable.

Then ‘M-x next-line-racer’ is called. Emacs seemingly freezes for some
time until it shows the point (cursor) at the end of the buffer and
message in mini-buffer displaying time it took to accomplish the
scrolling.

No demanding processes were run in the background during the experiment.

The Results
===========

Here I post measured times:

  Font Size       Time in Seconds
  normal           301.423
  +1              1055.157
  -1               487.935

Hope it helps.