5.0

5.0 | 3 ratings Rate this file 14 downloads (last 30 days) File Size: 3.68 KB File ID: #12422

timetic

by David Gleich

 

27 Sep 2006 (Updated 27 Sep 2006)

No BSD License  

An object oriented implementation of tic and toc for nested timing.

Download Now | Watch this File

File Information
Description

The tic and toc functions manipulate a single global time variable and are not suitable for internal function timing when external routines may also perform independent timing.

The timetic object rectifies this deficiency in Matlab and creates a proper object-oriented timing class.

t1 = timetic;
tic(t1);
% compute
t2 = timetic;
tic(t2);
% compute
toc(t2)
% compute
toc(t1)

The times reported by the two toc commands are precisely the times between the tic and toc commands.

Further, the timetic class extends the tic/toc paradigm by adding pause, start, and set operations to manipulate a timer.

tt = timetic;
tic(t1);
pause(t1);
% do some complicated output
start(t1); % restarts t1 without resetting the total elapsed time
toc(t1);

MATLAB release MATLAB 7 (R14)
Zip File Content  
Other Files @timetic/display.m,
@timetic/elapsed.m,
@timetic/pause.m,
@timetic/set.m,
@timetic/start.m,
@timetic/tic.m,
@timetic/timetic.m,
@timetic/toc.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
19 Oct 2006 master user

good

22 Feb 2008 alex barnett

Very useful & just what I was looking for. Please make this part of standard Matlab distribution!

21 Oct 2009 Jan Simon

Matlab 2008b and higher support multiple TIC TOC timers: t1 = tic; pause(1), t2 = tic; pause(2); toc(t1), toc(t2). But the commands "pause" and "start" can be useful for measuring processing time.
H1-line, descriptive help, date and author mentioned and it works.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
clock David Gleich 22 Oct 2008 08:41:27
fun David Gleich 22 Oct 2008 08:41:27
nested timers timer timing David Gleich 22 Oct 2008 08:41:27
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com