Measure real time

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.


rtime(a1, a2, …)


rtime() returns the real time that elapsed since the start of the current MuPAD® session. It is measured in milliseconds.

rtime(a1, a2, ...) returns the real time needed to evaluate all arguments.

The result of rtime is the real time. Thus, rtime can be used to measure the total time spent by the MuPAD process as well as by external processes spawned from inside the MuPAD session. Note that an interactive call of rtime() is not very useful because the idle time is included. However, rtime(a1, a2, ...) often yields a useful and more realistic timing than time(a1, a2, ...) if the evaluation of the arguments spawns external processes. For example, it can be useful for measuring time for numerical computations because some routines of the numeric library call external numerical tools using hardware floats.

If there are no running external processes besides MuPAD, the timings returned by rtime(a1, a2, ...) and time(a1, a2, ...) roughly coincide.

On computers without “time-sharing”, such as the Macintosh computer, real time and CPU time roughly coincide.

rtime is a function of the system kernel.


Example 1

Use rtime to compute the elapsed hours, minutes and seconds since this session was started:

t := rtime()/1000:
h := trunc(t/3600):
m := trunc(t/60 - h*60):
s := trunc(t - m*60 - h*3600):
print(Unquoted, "This session is running for " .
                h . " hours, " .
                m . " minutes and " .
                s . " seconds.")
session is running for 0 hours, 0 minutes and 10 seconds. 
delete t, h, m, s:


a1, a2, …

Arbitrary MuPAD objects

Return Values

Nonnegative integer giving the elapsed time in milliseconds.

See Also

MuPAD Functions