Current date and time.
t = clock
clock returns a 1x6 row vector, containing the year (four digits), the month, the day, the hour, the minute and the second of the current date and time. All numbers are integers, except for the seconds which are fractional. The absolute precision is plus or minus one second with respect to the computer's clock; the relative precision is plus or minus 1 microsecond on a Macintosh, and plus or minus 1 millisecond on Windows.
clock 1999 3 11 15 37 34.9167
Start stopwatch.
tic
tic resets the stopwatch. Typically, tic is used once at the beginning of the block to be timed.
Elapsed time of stopwatch.
elapsed_time = toc
toc gets the time elapsed since the last execution of tic. Typically, toc is used at the end of the block of statements to be timed.
On multi-tasking operating systems like Windows, Mac OS X and Unix, toc measures only the time spent in the LME application. Other processes do not have a large impact. For instance, typing tic at the command-line prompt, waiting 5 seconds, and typing toc will show a value much smaller than 5.
tic; x = eig(rand(200)); toc 0.3046