From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.help Subject: Re: Accelerating Emacs? Date: Fri, 28 Oct 2005 08:59:40 +0000 Organization: muc.de e.V. -- private internet access Message-ID: References: NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1130512874 30345 80.91.229.2 (28 Oct 2005 15:21:14 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 28 Oct 2005 15:21:14 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Oct 28 17:21:12 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EVW04-0002DA-RH for geh-help-gnu-emacs@m.gmane.org; Fri, 28 Oct 2005 17:18:37 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EVW04-0000o7-9C for geh-help-gnu-emacs@m.gmane.org; Fri, 28 Oct 2005 11:18:36 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news4.google.com!news.glorb.com!news.germany.com!news.space.net!news.muc.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 81 Original-NNTP-Posting-Host: acm.muc.de Original-X-Trace: marvin.muc.de 1130507342 72641 193.149.49.134 (28 Oct 2005 13:49:02 GMT) Original-X-Complaints-To: news-admin@muc.de Original-NNTP-Posting-Date: 28 Oct 2005 13:49:02 GMT User-Agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686)) Original-Xref: shelby.stanford.edu gnu.emacs.help:135068 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:30659 Archived-At: Herbert Euler wrote on Fri, 28 Oct 2005 13:53:08 +0800: >>From: "Flying Grass" 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] 0 (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").