tictoc_test, an Octave code which calls tic() and toc(), which compute elapsed time.
Octave includes two functions tic() and toc(). If tic() is called before something is to be timed, and toc() is called afterward, then toc() will either print the elapsed wallclock time if its value is not being copied to a variable, or return the value of the elapsed wallclock time to a variable.
To time an entire program, the simplest method to get the elapsed wallclock time is to call tic before you run the program and toc() afterwards:
tic my_program tocIf toc() is called without an output argument, it prints the elapsed time. or you can save the output from toc() and print it yourself.
tic my_program wtime = toc fprintf ( 1, ' MY_PROGRAM took %f seconds to run.\n', wtime );
For parallel programming, the important thing to measure is the elapsed wallclock time. This can be found by subtracting an initial reading of the wallclock time from a final one.
The computer code and data files described and made available on this web page are distributed under the MIT license
tictoc_test is available in a MATLAB version and an Octave version and a Python version.
timer_test, an Octave code which demonstrates how to compute cpu time or elapsed time.
timestamp, an Octave code which prints out the current ymdhms date.
wtime, an Octave code which returns a reading of the wall clock time in seconds.