Code covered by the BSD License  

Highlights from
Test Tools - Utilities for unit tests

Test Tools - Utilities for unit tests

by

 

06 Dec 2000 (Updated )

Tools that facilitate debugging or writing unit test for MATLAB functions.

[t1,t2]=timesim(model)
function [t1,t2]=timesim(model)
% TIMESIM('model') records time consumed to run SIM('model')
%
%     Without output arguments, displays a message in the MATLAB window
%     indicating the name of model being run, and then how much CPU and Wall
%     Clock time it took to run the model.
%
%     CPU=TIMESIM('model') returns the amount of CPU time required to run
%     the model.
%     
%     [CPU,WCLOCK]=TIMESIM('model') returns the amount of CPU and Wall Clock
%     time required to run the model.
%
%     Note that the Wall Clock time is more sensitive to system load than is
%     the CPU time.
%
%     See also TIC, TOC, CPUTIME, TIME.
   
% $Source: /home/stpierre/cvsroot/matlab/tools/test_tools/timesim.m,v $
% $Revision: 1.3 $
% $Date: 2009-07-19 23:21:54 $

% Copyright (c) 2001-2009, Jay A. St. Pierre.  All rights reserved.


if nargout==0
  fprintf(1, 'Running %s...\t', model);
end
  
tic;
cpu = cputime;

evalin('caller', ['sim(''',model,''')']);

cpu    = cputime-cpu;
wclock = toc;

if nargout==0
  fprintf(1, 'cpu = %.2f sec, wclock = %.2f sec\n', cpu, wclock);
else
  t1 = cpu;
  t2 = wclock;
end

Contact us