MATLAB Magical Mystery timing behavior
Posted
by Jacob Lyles
on Stack Overflow
See other posts from Stack Overflow
or by Jacob Lyles
Published on 2009-08-21T18:08:00Z
Indexed on
2010/03/18
18:41 UTC
Read the original article
Hit count: 272
matlab
I am experiencing some very odd timing behavior from a function I wrote. If I wrap my function inside another empty container function, it gets a 3x speedup.
>
> tic; foo(args); toc
time elapsed: ~140 seconds
>
>tic; bar(args); toc
time elapsed: ~35 seconds
Here's the kicker - the definition of bar():
define bar(args)
foo(args)
end
Is there some sort of optimization that gets triggered in MATLAB for nested function calls? Should I be adding a dummy function to every function that I write?
© Stack Overflow or respective owner