Why does adding a class to a package significant slow down performance?
Mostra commenti meno recenti
I have an application where I am loading a large amount of data from a test instrument (~40mb), extracting the data I need, fitting it to a curve, and performing some additional simple analyses. I converted the code from m-file functions to a classdef with a minimal performance hit. However, when I added the classes and functions to a package ("+" notation), the time to execute increased dramatically. The only difference was whether or not the top-level directory was formatted as a package and imported vs. putting it on the Matlab path. All of underlying code (including fully OO classes) were the same in either case.
One thing note that is specific to my case is that there is a core analysis function that is run ~300 times, with some sub-functions running ~2700 times. I believe that the inefficiencies are coming from calling this function from within the package.
I have used the profiler to eliminate as many inefficiencies as possible. This includes pre-allocation, removing redundant function calls, etc.
Any explanation for the large performance drop? Any suggestions for working around it?
4 Commenti
Sean de Wolski
il 3 Gen 2013
Hi Jordan,
Please contact us with a simple example and reference this thread.
%Sean
per isakson
il 4 Gen 2013
Modificato: per isakson
il 10 Gen 2013
I've made a simple code (R2012a) based on your description. With and without IMPORT and with and without the accelerator/JIT on (undocumentedmatlab.com). I see no significant differences. 14 seconds in all cases with a million iteration in the innermost loop.
>> feature('accel','off')
>> SignificantlySlower_test
ans =
13.3328 13.3486
>> feature('accel','on')
>> SignificantlySlower_test
ans =
14.6540 14.7412
Pierre
il 10 Gen 2013
Hello everyone,
I have the same problem (I use R2009b). And a similar performance problem append when doing a "cd" of directory containing (lot of) packages...
Sean, do you have some tips ? Thanks,
Pierre
Daniel Shub
il 10 Gen 2013
@pierre post this as a new question. Please include all the details needed to recreate the problem. Ideally a single MATLAB script that would create a folder with a bunch of packages and time the cd compared to a folder with a bunch of subfolders.
Risposte (0)
Categorie
Scopri di più su Whos in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!