From: Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
Cc: emacs-devel@gnu.org
Subject: interactive feel of Emacs: the need for speed, and -Q [measure.el]
Date: Mon, 30 Mar 2020 07:00:46 +0200 [thread overview]
Message-ID: <87tv26qvwh.fsf@ebih.ebihd> (raw)
Elisp: Last in this post, for the impatient.
Question: Second last in this post, for the ... whatever.
Some time ago, I assembled a supposedly gamer computer.
This sounds cool but actually it was easy, anyone can do
it, it is just a matter of money. (This should be
contrasted to all other paths of life, which are 100%
altruistic. Errr)
Anyway before that, I had an RPi, which I used as
a general-purpose computer. I got used to the low speed
and didn't feel that was a problem.
Now when I'm in game mode, I do experience a significant
decrease in compile time and such tasks, and a noticable
speedup WRT the interactive feel of Emacs.
I have an Elisp program [last] which I ran with the RPi,
and now on this computer. Three functions are executed
10 000 times each, and then the execution times
are outputted.
The unit is "a float number of seconds since the epoch",
as `float-time' is used.
On the RPi, times were 0.08, 0.38, and 0.55. On the gamer
computer, the same tests are done in times 0.01, 0.01,
and 0.05. (Maybe 0.01 indicates "too fast to measure"?)
So if I've done the math correctly, comparing the two
computers, the gamer computer has at least an 88%, 97%,
and 91% edge!
Still, when I invoke Emacs with -Q, the interactive feel
is much faster. This was true on the RPi as well, and the
relative difference was felt to be roughly the same.
The explanation given when this has been discussed is
that a lot of configuration/extension imposes hooks that
slow down the interactive feel. However I can't say
a rely a lot on hooks. When I do, they are one line of
Elisp to toggle `line-number-mode', and such. I _do_ have
a lot of Elisp (some 7 000 lines), *but* what I can see it
is for the most part just chunks of code that are not
used on an everyday basis. I have as much zsh shell
functions and they certainly do not slow zsh down by just
being there!
So I wonder, what exactly is brought in _without_ -Q that
slow Emacs down, and in particular the interactive feel?
Thanks for reading :)
;;; -*- lexical-binding: t -*-
;;;
;;; this file: http://user.it.uu.se/~embe8573/emacs-init/measure.el
;;; https://dataswamp.org/~incal/emacs-init/measure.el
(require 'cl-lib)
(defun point-at-final-line-1 ()
(= (line-number-at-pos)
(line-number-at-pos (point-max)) ))
(defun point-at-final-line-2 ()
(save-excursion
(end-of-line)
(= 1 (forward-line) )))
(defun point-at-final-line-3 ()
(= (line-end-position) (point-max)) )
(defmacro measure-time (&rest body)
"Measure and return the running time of the code block.
Thanks: http://nullprogram.com/blog/2009/05/28/"
(declare (indent defun))
(let ((start (make-symbol "start")))
`(let ((,start (float-time)))
,@body
(- (float-time) ,start) )))
(defun create-random-list (max len)
(let ((l '()))
(cl-loop repeat len do
(push (random max) l))
l) )
(defun test-final-line-f (fun pos-list)
(cl-loop for p in pos-list do
(goto-char p)
(apply fun nil) ))
(defun test-final-line (its)
(let*((max (point-max))
(pos-list (create-random-list max its))
(funs (list #'point-at-final-line-1
#'point-at-final-line-2
#'point-at-final-line-3) )
(times '()) )
(cl-loop for f in funs do
(push (list f (measure-time (test-final-line-f f pos-list))) times) )
(goto-char (point-max))
(let ((sorted-times (cl-sort times #'< :key #'cadr)))
(cl-loop for time in sorted-times do
(insert (format "\n;; %s %0.2f" (car time) (cadr time))) ))))
;; (test-final-line 10000)
;; ^eval me
;; results on RPi3:
;;
;; point-at-final-line-3 0.08
;; point-at-final-line-2 0.38
;; point-at-final-line-1 0.55
;;
;; gamer computer:
;;
;; point-at-final-line-3 0.01
;; point-at-final-line-2 0.01
;; point-at-final-line-1 0.05
;;
;; improvements:
;;
;; (format "%.0f%%" (- 100 (* 100 (/ 0.01 0.08)))) ; 88%
;; (format "%.0f%%" (- 100 (* 100 (/ 0.01 0.38)))) ; 97%
;; (format "%.0f%%" (- 100 (* 100 (/ 0.05 0.55)))) ; 91%
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
reply other threads:[~2020-03-30 5:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=87tv26qvwh.fsf@ebih.ebihd \
--to=help-gnu-emacs@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=moasenwood@zoho.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.
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).