octave-maintainers
[Top][All Lists]
Advanced

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

FYI: optimized strcat


From: Jaroslav Hajek
Subject: FYI: optimized strcat
Date: Tue, 29 Dec 2009 05:56:16 +0100

hi all,

by the following two patches,
http://hg.savannah.gnu.org/hgweb/octave/rev/691b4ba32425
http://hg.savannah.gnu.org/hgweb/octave/rev/e60f038146e1

I optimized the strcat function using vectorized, cellfun-based code,
in particular taking advantage of a recent cellfun improvement.
As a result, strcat got significantly faster, as shown by the
following benchmark :

n = 5000;
str = num2str (25*[1:n].');
tic; strcat ("GNU ", str, "Octave"); toc
str = cellstr (str);
tic; strcat ("GNU ", str, "Octave"); toc
tic; strcat ("GNU ", str{:}, "Octave"); toc
tic; strcat ({"GNU "; "Octave"}, str{:}); toc

on Core 2 Duo @ 1.83 GHz, g++ 4.3 -O3 -march=native, prior to the
changes, I got:

Elapsed time is 0.589939 seconds.
Elapsed time is 0.577834 seconds.
Elapsed time is 1.36994 seconds.
Elapsed time is 2.02466 seconds.
Elapsed time is 15.3334 seconds.

and with the new changes, I get:

Elapsed time is 0.0527599 seconds.
Elapsed time is 0.033006 seconds.
Elapsed time is 0.0518899 seconds.
Elapsed time is 0.0585291 seconds.
Elapsed time is 0.205875 seconds.

i.e. a 10x - 70x speed-up.


-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

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