The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Performance of Set Observable properties of Matlab Objects
Replies: 1   Last Post: Jul 18, 2013 3:41 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Joe Burgel

Posts: 25
Registered: 12/7/04
Performance of Set Observable properties of Matlab Objects
Posted: May 9, 2013 10:19 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


This is more of a comment then a request for help but if any ML workers and give a reason for it, I'd love to know why. This is the result of a muliti-hour effort to performance optimize my code. I was using the profiler and kept getting one method that was taking up to 35 seconds to execute. The profiler (profile) was no help in that it said the time was being used as 'self time' defined as:
"Self time is the time spent in a function excluding the time spent in its child functions. Self time also includes overhead resulting from the process of profiling."
I added up all the time each line took to execute in my method and it added up to about .4 sec so that left 31.6 sec un-accounted for and no way to further deduce what was taking so long.

I then began a 'divide and concur' approach to finding the issue and determined it was being caused by clearing a Matlab OO property defined as follows:

properties (Access = 'public', Dependent = true, SetObservable)
Data %The Data for the parameter. see Dimension. For type

When I changed this to:

properties (Access = 'public', Dependent = true)
Data %The Data for the parameter. see Dimension. For type

The time to execute my method went to about .4 sec. So, I knew I was on to something. I then made sure it wasn't anything listening to this property and nothing was. NO LISTENERS on this property. Now, here's the interesting thing I found. I set the Data property back to SetObservable and ran the following code. Among other things, ResetCals() method simply sets Data = [];

ThisFile = load(FileName,'-mat');
Elapsed time is 32.078356 seconds.

Now, this code:

ThisFile = load(FileName,'-mat');
File = ThisFile.ThisFile;
Vehicle = File.Configurations(1).Vehicle;

Elapsed time is 0.478578 seconds.

A MASSIVE 31.5 seconds faster! Vehicle is a child object of a Configuration object. Vehicle keeps a reference property to it's parent configuration so the two snippets are calling the same method ultimately. Now, I set the Data property back to:
properties (Access = 'public', Dependent = true)
and re-run the same snippets and got these times respectively:

Elapsed time is 0.347201 seconds.
Elapsed time is 0.314816 seconds.

So, this calling syntax together with a SetObservable property being called caused a 31 second difference in time. I have no idea why? Anyone?

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.