[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Accelerating Emacs?
Re: Accelerating Emacs?
Fri, 28 Oct 2005 08:59:40 +0000
tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686))
Herbert Euler <address@hidden> wrote on Fri, 28 Oct 2005
>>From: "Flying Grass" <address@hidden> To: address@hidden
>>Subject: Re: Accelerating Emacs? Date: 27 Oct 2005 19:59:30 -0700
> I tried that, but it is only effective when making small changes i.e.
> deleting a character. On my test on a 8612 KB size file, Emacs is not
> quick enough yet. The sed command
> sed 's/[A-Z]/0/g' test
> needs 17s to finish its job, and vim command
> needs 1min 7s, but even 20min is still not enough for the Emacs command
> (in fundamental-mode)
> (replace-regexp "[A-Z]" "0" nil nil nil)
Why are you using this lisp form rather than using the normal Emacs
replacement command C-M-% (query-replace-regexp)? Could you try this
command in your large file, entering the arguments as follows:
C-M-% [A-Z] <ret> 0 <ret> (Use M-x query-replace-regexp if you haven't
got the keybinding.)
, then start your stop watch as you type "!" (which means replace all
The lisp form you quoted merely replaces one occurrence, so presumably
you embedded this in a loop to do the timing. The doc-string for
replace-regexp actually recommends against doing this, suggesting a
better way, as follows:
This function [replace-regexp] is usually the wrong thing to use in
a Lisp program. What you probably want is a loop like this:
(while (re-search-forward REGEXP nil t)
(replace-match TO-STRING nil nil))
which will run faster and will not set the mark or print anything.
Could you perhaps time this on your 8612 KB file? I doubt it'll be quite
as fast as vim's 67 seconds, but I'd be surprised if it takes anything
like 20 minutes.
> Besides, Emacs uses about 128MB memory. And when I tried to mark all
> text, Emacs complains about the memory.
What are you doing to have Emacs use 128MB memory? I frequently run two
copies of Emacs simultaneously (occasionally even 3), and I've only got
64MB of RAM. :-)
> So I think it is better of using tools such as sed and vim to edit file
> bigger than 5MB instead of Emacs, since Emacs is not good at this job.
You're surely right here, up to a point. If by "editing" you mean simple
mechanical changes repeated a vast number of times, Emacs is definitely
not the right tool. This is what sed is for, as you know. Emacs is
optimised for interactive editing of human-readable text files, which
tend to be smaller than 1MB. For tasks in between (say, extracting
information from log files), you'd want something like an AWK, Perl, or
But I think the nature of the task rather than the size of the file is
the prime criterion for deciding on the tool. I sometimes massage data
in ~40 Mb files (for example leafnode (the newsreader)'s .overview files)
and find Emacs fast enough (just a little sluggish), even on my 166 MHz
> Guanpeng Xu
Alan Mackenzie (Munich, Germany)
Email: address@hidden; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").
Re: Accelerating Emacs?, David Kastrup, 2005/10/28
Re: Accelerating Emacs?, Thien-Thi Nguyen, 2005/10/28
Re: Accelerating Emacs?,
Alan Mackenzie <=
- Re: Accelerating Emacs?, (continued)