File Exchange

image thumbnail

timetic

version 1.0.0.0 (3.68 KB) by David Gleich
An object oriented implementation of tic and toc for nested timing.

3 Downloads

Updated 27 Sep 2006

No License

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);

Comments and Ratings (3)

Jan

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.

alex barnett

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

master user

good

MATLAB Release Compatibility
Created with R14
Compatible with any release
Platform Compatibility
Windows macOS Linux