From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Emanuel Berg via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help,gmane.emacs.devel Subject: interactive feel of Emacs: the need for speed, and -Q [measure.el] Date: Mon, 30 Mar 2020 07:00:46 +0200 Message-ID: <87tv26qvwh.fsf@ebih.ebihd> Reply-To: Emanuel Berg Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="129004"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: emacs-devel@gnu.org To: help-gnu-emacs@gnu.org Cancel-Lock: sha1:NiikE9lp0YUuilf6dwHqMW0+7YM= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 30 07:01:29 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jImYC-000XSf-Jk for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 30 Mar 2020 07:01:28 +0200 Original-Received: from localhost ([::1]:44984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jImYB-0001d9-LJ for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 30 Mar 2020 01:01:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40832) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jImXh-0001cj-5f for help-gnu-emacs@gnu.org; Mon, 30 Mar 2020 01:00:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jImXf-0001pK-Ge for help-gnu-emacs@gnu.org; Mon, 30 Mar 2020 01:00:57 -0400 Original-Received: from ciao.gmane.io ([159.69.161.202]:46086) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jImXe-0001jh-R1 for help-gnu-emacs@gnu.org; Mon, 30 Mar 2020 01:00:55 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1jImXc-000WwA-MD for help-gnu-emacs@gnu.org; Mon, 30 Mar 2020 07:00:52 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Original-Followup-To: gmane.emacs.help Mail-Copies-To: never X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 159.69.161.202 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:122713 gmane.emacs.devel:245988 Archived-At: 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