octave-maintainers
[Top][All Lists]
Advanced

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

cellfun optimizations


From: Jaroslav Hajek
Subject: cellfun optimizations
Date: Wed, 18 Mar 2009 21:40:01 +0100

hi,

following a recent discussion with F. Potorti, I made some
optimizations within cellfun. The issue can be demonstrated like this:

a = cell (1e6, 1);
tic; cellfun (@isempty, a); toc
tic; cellfun (@isempty, a, "UniformOutput", false); toc

using a recent tip, I get:

Elapsed time is 3.81208 seconds.
Elapsed time is 1.16292 seconds.

This shows that the uniform output version is significantly slower.
The reason was that the very-high-level subsasgn functions was used to
insert each computed element to the proper place, which involves a lot
of overhead. I created a helper virtual class machinery to allow
optimize the most common case when the result type does not change
during the computation, and also avoided an unnecessary copying of the
input argument.

Using current tip, I get

Elapsed time is 1.08854 seconds.
Elapsed time is 1.0643 seconds.

which shows that this optimization brings the uniform output version
on par with the non-uniform one (which requires somewhat less work).

enjoy

-- 
RNDr. Jaroslav Hajek
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]