all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
Subject: Re: Accelerating Emacs?
Date: Fri, 28 Oct 2005 08:59:40 +0000	[thread overview]
Message-ID: <s9psjd.46.ln@acm.acm> (raw)
In-Reply-To: mailman.13033.1130478796.20277.help-gnu-emacs@gnu.org

Herbert Euler <herberteuler@hotmail.com> wrote on Fri, 28 Oct 2005
13:53:08 +0800:
>>From: "Flying Grass" <wcy123@gmail.com> To: help-gnu-emacs@gnu.org
>>Subject: Re: Accelerating Emacs?  Date: 27 Oct 2005 19:59:30 -0700

>>try fundamental-mode

> 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

>     :1,$:s/[A-Z]/0/g

> 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
further occurances).


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
Python script.

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
PC.

> Regards,
> Guanpeng Xu

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").

       reply	other threads:[~2005-10-28  8:59 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.13033.1130478796.20277.help-gnu-emacs@gnu.org>
2005-10-28  8:59 ` Alan Mackenzie [this message]
2005-10-28 18:28   ` Accelerating Emacs? Herbert Euler
2005-10-29 10:18     ` Eli Zaretskii
2005-10-29 11:44       ` Herbert Euler
2005-10-29 15:43         ` Eli Zaretskii
2005-10-31  3:26           ` Herbert Euler
     [not found] <mailman.13061.1130499101.20277.help-gnu-emacs@gnu.org>
2005-10-28 12:08 ` David Kastrup
2005-10-28 13:43   ` Herbert Euler
2005-10-28 12:49 ` Thien-Thi Nguyen
2005-11-01  4:55 ` Stefan Monnier
     [not found] <mailman.12998.1130466347.20277.help-gnu-emacs@gnu.org>
2005-10-28  2:59 ` Flying Grass
2005-10-28  5:53   ` Herbert Euler
2005-10-28  8:23     ` Eli Zaretskii
2005-10-28 11:31       ` Herbert Euler
2005-10-28 13:13         ` Eli Zaretskii
     [not found]     ` <mailman.13044.1130487836.20277.help-gnu-emacs@gnu.org>
2005-10-28 10:36       ` Per Abrahamsen
2005-10-28  2:25 Herbert Euler
2005-10-28  8:25 ` Eli Zaretskii
2005-10-28 11:38   ` Herbert Euler
2005-10-28 13:16     ` Eli Zaretskii
     [not found] ` <mailman.13045.1130488013.20277.help-gnu-emacs@gnu.org>
2005-11-28  1:09   ` Christopher C. Stacy
2005-11-28  5:21     ` Eli Zaretskii
     [not found]     ` <mailman.17015.1133155279.20277.help-gnu-emacs@gnu.org>
2005-11-28  5:46       ` Pascal Bourguignon
2005-11-28 10:26         ` Thien-Thi Nguyen
2005-12-01  4:43         ` Stefan Monnier

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s9psjd.46.ln@acm.acm \
    --to=acm@muc.de \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.