octave-maintainers
[Top][All Lists]
Advanced

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

Re: strrep vs. regexprep


From: Philip Nienhuis
Subject: Re: strrep vs. regexprep
Date: Mon, 24 Oct 2011 19:56:06 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.11) Gecko/20100701 SeaMonkey/2.0.6

Rik wrote:
On 10/23/2011 02:21 PM, address@hidden wrote:
Q2:
There's ample room for improvement in various parts I wrote. But I need to
know:
which one is faster,  strrep  or  regexprep ?
Both of these are needed in several places, but AFAICS regexprep is more
versatile.

Philip,

strrep is much faster, approximately 20X faster, than regexprep.  At some

That's unfortunate, as regexprep is unavoidable at several stages of strread.m, for processing of the entire input string. E.g. condensing consecutive heterogeneous whitespace into one char.
I'll try to turn it into "pre-processing" as much as possible.

Of course, regexp is much more complicated (I envision much more "if"s in its code). But a factor of 20 is, well, outrageous IMO.

point it would be nice to investigate why using the PCRE library is so much
slower.For now, however, try to keep everything using Octave's own
internal string functions such as strrep, strtok, strfind, strsplit, etc.
I have updated nearly every function except strtok in the scripts/strings
directory over the last month.  They have all been tweaked for better
performance.  Also, in general things are faster when operating on 2-D
character arrays rather than cell array of strings.  One doesn't always
have a choice though.

I'll keep it in mind.

Thanks,

Philip


reply via email to

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