Stuart’s MATLAB Videos

Watch and Learn

Speeding up Doug’s solution with the profiler

Last week, I posed a Puzzler. I solved it the hard way, because I did not know any of the fancy math that the people in the comments section mentioned. I will leave the closed form solution to them and the cited references. The monte carlo solution that I came up with gave a great opportunity for code optimization via the profiler. Here is a six minute video that shows the four iterations my code took. I ended up restructuring so that I did not have clarifying “do nothing” code. I got rid of a clarifying subfunction, and I stopped keeping track of all the iterations, and just stored the final result in an accumulator. These optimizations cut the execution time by a factor of ten.
Video Player is loading.
Current Time 0:00
Duration 0:00
Loaded: 0%
Stream Type LIVE
Remaining Time 0:00
 
1x
  • Chapters
  • descriptions off, selected
  • captions off, selected
  • en (Main), selected
    |
    • print

    Comments

    To leave a comment, please click here to sign in to your MathWorks Account or create a new one.

    Loading...
    Go to top of page