Code profiling and micro-benchmarks can be useful to discover hot spots in code that might be targets for improving efficiency and overall execution time. Matlab has long had an effective profiler built in from the factory.
Commercial and free software often prioritized quality and correctness over speed as part of a good quality software product. I have made numerous code contributions to projects such as Numpy and Scipy with regard to performance and robustness. Matlab is no exception–in the early days of my engineering career I used interpolation functions a lot, and realized that by taking advantage of certain characteristics of my problem, I could remove unneeded checks and steps inside Matlab’s factory interpolation functions. Moreover, there are cases where the Matlab factory functions are simply not optimized due to development time constraints.
Yair Altman has expertise with the undocumented scripts inside Matlab that many Matlab users rely on. He has written a three-part series on profiling and optimizing Matlab factory code, which I find to be worthwhile reading even for general Matlab code optimization.