[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: strrep vs. regexprep
From: |
Rik |
Subject: |
Re: strrep vs. regexprep |
Date: |
Mon, 24 Oct 2011 11:35:51 -0700 |
On 10/24/2011 10:56 AM, Philip Nienhuis wrote:
> 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.
Yes, I've become accustomed to Perl where regular expression operations are
nearly instantaneous and it *hurts* to give up coding with them.
The data is emphatic, however, that regexp are slow in Octave.
--Rik