0

I want to log the name of all the functions that are called for each Object instance in MATLAB!

For example if we have this class:

classdef ClassName

   methods
      function obj = ClassName()
         ...
      end
      function ordinaryMethod()
         ...
      end
   end

end

And i run the following code:

testObj = ClassName();
testObj.ordinaryMethod();

I can somehow log that the ordinaryMethod was called for testObj which is a instance of ClassName. To make it clear, I dont want to just get a list of all the function names, I only need those that are used in my program.

Can anyone give me ideas, how i can achieve this?

EDIT: Ideal solution is that I don't have to change the function codes!

1 Answer 1

1

The simplest way to log all function calls is to use the profile viewer. To open this issue the command profile viewer, or use the 'Run and time' option instead of the 'Run' option in the editor taskbar.

Once you have exercised your code sufficiently well (to make sure you catch all calls!), then you should stop profiling and look at the result. In it you will find lines with ClassName>ClassName.ordinaryMethod indicating that this function has been called. (Of course, you also know how long it spent in each function call). Using Ctrl-F helps you find what you are looking for, as does clicking on the heading "Function Name" which sorts the entries in alphabetic order.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.