next up previous contents
Next: Operating System Commands Up: Communicating with the Operating Previous: Communicating with the Operating

Date and Time

The command date returns the current date and time as a string.
> date();
If you prefer to know the number of seconds since 00:00:00 GMT, January 1, 1970 in seconds, then issue the rtime command (running time) with no arguments.
> rtime();
The rtime function can also except an expression as a parameter. In this form, rtime returns the time in seconds needed to evaluate this expression.
 for i from 1 to 100001 by 500 do
   lprint(i, rtime(factorial(i)));
As an aside, note that the running time does not grow linearly with the size of the factorial we are computing. This is because the built-in factorial function approximates the true value for large numbers using a variant of the gamma function (see §[*] in Part [*] -The Reference Guide and [11]). Chapter [*] Measuring Performance explores this and related functions further.

Gaston Gonnet