Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!32g2000yqj.googlegroups.com!not-for-mail
From: Rune Allnor <allnor@tele.ntnu.no>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Script will take far too long..
Date: Wed, 22 Jul 2009 09:04:37 -0700 (PDT)
Organization: http://groups.google.com
Lines: 45
Message-ID: <252eb97c-b625-4743-8807-2f79a75cd301@32g2000yqj.googlegroups.com>
References: <h454s2$k0u$1@fred.mathworks.com> <4fe65105-648f-4e77-9dd4-6a52da136c5f@t13g2000yqt.googlegroups.com> 
	<h45m71$k6s$1@fred.mathworks.com>
NNTP-Posting-Host: 77.19.3.157
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1248278678 585 127.0.0.1 (22 Jul 2009 16:04:38 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 22 Jul 2009 16:04:38 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: 32g2000yqj.googlegroups.com; posting-host=77.19.3.157; 
	posting-account=VAp5gAkAAAAmkCze5hvZtMeedpZWNthI
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; 
	Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 
	3.5.21022),gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:557595


On 22 Jul, 02:24, "Jan Simon" <matlab.THIS_Y...@nMINUSsimon.de> wrote:
> Dear Rune Allnor!
>
> > There is something wrong. A 1GB computer should have no problems
> > whatsoever with handling lines of 1.5 MB.
>
> Waiting 40 min for regexprep is not a "problem", but just slow.

The time is a problem for several reasons:

1) It takes several orders of magnitudes more
   than it needs to (see below)
2) The time is the difference between the job
   getting done at all, or not.

> Matlab 6.5 takes 10 min for replacing 125.000 'A_A' with '1' in a 1.5MB string on my 1500MHz PentiumM -- without file access!

On R2006a:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
N = 1500000;
s = char('B'*ones(1,N));
Naa = 200000;

for n=1:5:5*Naa
s(n:n+2)='A_A';
end

rexp = 'A_A';
tic
regexprep(s,rexp,'1');
toc

tic
strrep(s,'A_A','1');
toc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Elapsed time is 65.978407 seconds.
Elapsed time is 0.018985 seconds.

So the OP should be able to do the whole job in a
couple of seconds. With his present computer.

Rune