help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Accelerating Emacs?


From: Thien-Thi Nguyen
Subject: Re: Accelerating Emacs?
Date: Fri, 28 Oct 2005 14:49:20 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

"Herbert Euler" <herberteuler@hotmail.com> writes:

> (let ((i 0))
>   (while (< i 20000)
>     (let ((j 0) s)
>       (while (< j 10)
>       (setq s (concat s (char-to-string (+ 50 (random 50))))
>             j (1+ j)))
>       (insert s "\n"))
>     (setq i (1+ i))))

using repeated `concat' followed by `insert' generates a lot of garbage
to be collected (primarily temporary strings).  here's a variation that
goes faster (how much faster depends on many factors!):

(funcall
 (byte-compile
  (lambda ()
    (insert (with-temp-buffer
              (set-buffer-multibyte nil)
              (let ((s (concat (make-string 10 0) "\n")))
                (dotimes (i 20000)
                  (dotimes (j 10)
                    (aset s j (+ 50 (random 50))))
                  (insert s)))
              (buffer-string))))))

it may be unsuitable for other data domains, but that's by design...

> So perhaps I can restate it like this: if Emacs starts to be slow in
> some condition, it is better of using some other tools instead of
> it. And I find it very cool of running vim in Eshell.

the best tool is your brain, which is nice because it is portable, and
subject to "instead" only by its own admission.  if you can use it to
exploit other tools (including emacs) in various configurations, what
more is there to ask?

thi


reply via email to

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