[Top][All Lists]

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

More cellfun related benchmarks

From: Rik
Subject: More cellfun related benchmarks
Date: Sat, 06 Aug 2011 18:12:09 -0700



The previous test results I posted showed that cellfun is horribly slow
when the function used is defined in an m-file.  Further testing shows that
there is also a difference between passing a function name as an input or a
function handle.


cellfun with string "sin"

cellfun with function handle @sin
1.2197    +13% slower

cellfun with anonymous function @(x) sin (x)
1.4817    +37% slower

cellfun with "isempty"

cellfun with @isempty
1.2066    ~100X slower

If the function happens to be one of the specialized ones that is directly
implemented by cellfun then the speedup is over 100X.

All of this suggests that cellfun should always be called with a string
argument since it will be faster than the equivalent function handle and
can potentially be much faster in common instances.

Accordingly, I went ahead and made the change for the core Octave functions
in this changeset
(http://hg.savannah.gnu.org/hgweb/octave/rev/cefd568ea073).  Running 'make
check' as a crude benchmark showed there was at least a small improvement
from the change.


reply via email to

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