matlab profiling lien-chi lai, cola lab 2010/05/06

8
MATLAB Profiling Lien-Chi Lai, COLA Lab 2010/05/06

Upload: barry-cunningham

Post on 21-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MATLAB Profiling Lien-Chi Lai, COLA Lab 2010/05/06

MATLAB Profiling

Lien-Chi Lai, COLA Lab2010/05/06

Page 2: MATLAB Profiling Lien-Chi Lai, COLA Lab 2010/05/06

Outline Tic & toc Clock Etime Profile

Page 3: MATLAB Profiling Lien-Chi Lai, COLA Lab 2010/05/06

Tic & Toc

MATLAB Profiling3

tic – Start a stopwatch timer toc – Read the stopwatch timer tic and toc function work together to measure elapsed

time between the two Sample:

Tic & Toc

>> tic; % Start stopwatch>> inv(rand(500)); % Matrix inverse>> toc; % Stop and measure elapsed time

Page 4: MATLAB Profiling Lien-Chi Lai, COLA Lab 2010/05/06

Clock

MATLAB Profiling4

Returns current date and time as a vector The vector is in a decimal form contains six element

[year month day hour minute seconds] Sample:

Clock

>> fix(clock); % Rounds to integer display formatans = 2010 5 6 15 53 1

Page 5: MATLAB Profiling Lien-Chi Lai, COLA Lab 2010/05/06

Etime

MATLAB Profiling5

etime(t1, t0) returns the time in seconds that has elapsed between vectors t1 and t0

t0 and t1 must be the format returned by clock Sample:

Etime

>> t0 = clock; % Record initial time>> inv(rand(500)); % Matrix inverse>> t1 = clock; % Record final time>> etime(t1, t0); % Measure elapsed time

Page 6: MATLAB Profiling Lien-Chi Lai, COLA Lab 2010/05/06

Profile

MATLAB Profiling6

Returns summary of function calls and total time Sample: profile_test.m

Profile

% start the profiler and clear previous recordprofile on

for i=1:10 inv(rand(100));end

% stop the profilerprofile off

% save profile record as html profile reportprofsave(profile('info'), 'profile_results')

profile report % display profile report

Page 7: MATLAB Profiling Lien-Chi Lai, COLA Lab 2010/05/06

Profile – GUI

MATLAB Profiling7

As an alternative to the profile function select Desktop > Profiler to open the Profiler click the “Profiler” button do not include “.m” in the “Run this code” field

Profile - GUI

Page 8: MATLAB Profiling Lien-Chi Lai, COLA Lab 2010/05/06

Other Resources

MATLAB Profiling8

http://blogs.mathworks.com/videos/2006/10/19/profiler-to-find-code-bottlenecks/

Profile - GUI