MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

Performance


28


Measure Performance of Your Program ............. 28-2
Overview of Performance Timing Functions......... 28-2
Time Functions............................... 28-2
Time Portions of Code.......................... 28-2
The cputime Function vs. tic/toc and timeit.......... 28-3
Tips for Measuring Performance .................. 28-3

Profile to Improve Performance.................... 28-5
What Is Profiling?............................. 28-5
Profiling Process and Guidelines .................. 28-5
Using the Profiler ............................. 28-6
Profile Summary Report........................ 28-8
Profile Detail Report........................... 28-9

Use Profiler to Determine Code Coverage........... 28-12

Techniques to Improve Performance............... 28-14
Environment............................... 28-14
Code Structure .............................. 28-14
Programming Practices for Performance........... 28-14
Tips on Specific MATLAB Functions.............. 28-15

Preallocation .................................. 28-17
Preallocating a Nondouble Matrix............... 28-17

Vectorization.................................. 28-19
Using Vectorization .......................... 28-19
Array Operations............................ 28-20
Logical Array Operations...................... 28-22
Matrix Operations........................... 28-23
Ordering, Setting, and Counting Operations........ 28-24
Functions Commonly Used in Vectorization........ 28-26

xxviii Contents

Free download pdf