octave-maintainers
[Top][All Lists]
Advanced

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

Re: C++ version of regexprep.cc


From: Paul Kienzle
Subject: Re: C++ version of regexprep.cc
Date: Mon, 1 May 2006 21:07:37 -0400


On May 1, 2006, at 10:00 AM, David Bateman wrote:

While looking at how to eliminate the feval in regexprep, I felt it was
easier to in fact implement the linked list manner of building the
matches in regexp at the same time, and as you suspected it is much much
faster than resizing the return values at each new match. The time
comparison on my machine is

octave:1> s = repmat('s',[1,5]); regexp(s,'s')
ans =

  1  2  3  4  5

octave:2> s = repmat('s',[1,1000]); tic; regexp(s,'s'); toc
Elapsed time is 0.798393 seconds.
octave:3> s = repmat('s',[1,2000]); tic; regexp(s,'s'); toc
Elapsed time is 3.107239 seconds.
octave:4> s = repmat('s',[1,3000]); tic; regexp(s,'s'); toc
Elapsed time is 7.145126 seconds.

prior to converting to using a linked list and with the attached version is

octave:1>  s = repmat('s',[1,5]); regexp(s,'s')
ans =

  1  2  3  4  5

octave:2> s = repmat('s',[1,1000]); tic; regexp(s,'s'); toc
Elapsed time is 0.014191 seconds.
octave:3> s = repmat('s',[1,2000]); tic; regexp(s,'s'); toc
Elapsed time is 0.023567 seconds.
octave:4> s = repmat('s',[1,3000]); tic; regexp(s,'s'); toc
Elapsed time is 0.050476 seconds.

So it is linear time and not quadratic. What effect does this version
have on your xml4mat code? In any case I'm inclined to commit this
version as is, unless you see any other changes that you want to make
first. John comments?

David,

octave now goes quickly through the regular expression portion of the code.

I haven't yet confirmed that the results are consistent with matlab.

The next portion involves for loops such as the following:

  tag = cell(number_of_tags,4);
  for i=1:number_of_tags
   tag{i,1} = xml(tag_start(i):tag_end(i))
  end

which for 10000 tags is slow.

Are there octave routines for splitting/joining strings into cells
which are fast?

- Paul



reply via email to

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