1

I want to be able to measure performance of my code and find the lacking parts. What is the proper way to do that in Matlab? I know I can use just tic: and toc; functions to see the time passing but there might be more convenient way.

2 Answers 2

3

The most convenient way is to use the GUI profiler tool. You can find it in the dropdown menus (Desktop->Profiler), or you can start it from the command line by typing profile viewer. Then you enter the name of the function at the top of the window, hit "run", and wait till the code is done running. Clicking on the links brings you into the respective function, where you can see runtime line-by-line.

Note that timing code that runs very fast and for only a handful of iterations can be tricky; for these cases you may want to use the timeit function from the Matlab File Exchange.

enter image description here

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

Comments

1

The profile tool reports time spent on each function and in each line of code in the program.

It takes longer to implement so if you are analyzing a short piece of code, tic-toc will do the job better.

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.