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;
t2 = timetic;
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;
% do some complicated output
start(t1); % restarts t1 without resetting the total elapsed time
David Gleich (2021). timetic (https://www.mathworks.com/matlabcentral/fileexchange/12422-timetic), MATLAB Central File Exchange. Retrieved .
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!