Discussion:
fast string searches
(too old to reply)
rutiger
2007-01-14 20:12:09 UTC
Permalink
Does anybody know of any tricks or optimized functions for pattern
matching in strings? An example of what I am talking about is the
following:

debug> tic; indx = strmatch('sensor x velocity at aperture center
(DUNITS, PCS)', value_name ); toc
Elapsed time is 0.115318 seconds.

In MATLAB, however:

K>> tic; indx = strmatch('sensor x velocity at aperture center (DUNITS,
PCS)', value_name ); toc
Elapsed time is 0.001158 seconds.

So Octave is 100 times slower than MATLAB in this case. I can speed it
up by using this instead:

debug> tic; indx = find( strcmpi('sensor x velocity at aperture center
(DUNITS, PCS)', value_name ) ); toc
Elapsed time is 0.049141 seconds.

K>> tic; indx = find( strcmpi('sensor x velocity at aperture center
(DUNITS, PCS)', value_name ) ); toc
Elapsed time is 0.000227 seconds.

MATLAB is still amazingly faster. I haven't found anything on the
Octave mailing lists yet, so I am at a loss. This problem is causing a
function that executes in 20(sec) in MATLAB to execute in 5(min) in
Octave.
david bateman
2007-02-03 01:00:48 UTC
Permalink
Post by rutiger
Does anybody know of any tricks or optimized functions for pattern
matching in strings? An example of what I am talking about is the
debug> tic; indx = strmatch('sensor x velocity at aperture center
(DUNITS, PCS)', value_name ); toc
Elapsed time is 0.115318 seconds.
K>> tic; indx = strmatch('sensor x velocity at aperture center (DUNITS,
PCS)', value_name ); toc
Elapsed time is 0.001158 seconds.
So Octave is 100 times slower than MATLAB in this case. I can speed it
debug> tic; indx = find( strcmpi('sensor x velocity at aperture center
(DUNITS, PCS)', value_name ) ); toc
Elapsed time is 0.049141 seconds.
K>> tic; indx = find( strcmpi('sensor x velocity at aperture center
(DUNITS, PCS)', value_name ) ); toc
Elapsed time is 0.000227 seconds.
MATLAB is still amazingly faster. I haven't found anything on the
Octave mailing lists yet, so I am at a loss. This problem is causing a
function that executes in 20(sec) in MATLAB to execute in 5(min) in
Octave.
Yes indeed this is an issue with some versions of octave.. Some of
this is fixed in Octave 2.9.9 with compiled versions of the string
matching functions, some of it will be fixed when 2.9.10 is released..

D.

Loading...