Go to the first, previous, next, last section, table of contents.

### `time`

`time()`
  :: Returns a four element list consisting of total CPU time, GC time, the elapsed time and also total memory quantities requested from the start of current Asir session.

return
  list

- These are commands regarding CPU time and GC time.
- The GC time is the time regarded to spent by the garbage collector, and the CPU time is the time defined by subtracting the GC time from the total time consumed by command Asir. Their unit is `second.'
- Command `time()` returns total CPU time and GC time measured from the start of current Asir session. It also returns the elapsed time. Time unit is `second.' Moreover, it returns total memory quantities in words (usually 4 bytes) which are requested to the memory manager from the beginning of the current session. The return value is a list and the format is `[CPU time, GC time, Memory, Elapsed time]`.
- You can find the CPU time and GC time for some computation by taking the difference of the figure reported by `time()` at the beginning and the ending of the computation.
- Since arbitrary precision integers are NOT used for counting the total amount of memory request, the number will eventually happen to become meaningless due to integer overflow.
- When `cputime` switch is active by `ctrl()` or by `cputime()`, the execution time will be displayed after every evaluation of top level statement. In a program, however, in order to know the execution time for a sequence of computations, you have to use `time()` command, for an example.
- On UNIX, if `getrusage()` is available, `time()` reports reliable figures. On Windows NT it also gives reliable CPU time. However, on Windows 95/98, the reported time is nothing but the elapsed time of the real world. Therefore, the time elapsed in the debug-mode and the time of waiting for a reply to interruption prompting are added to the elapsed time.

    [72] T0=time();
    [2.390885,0.484358,46560,9.157768]
    [73] G=hgr(katsura(4),[u4,u3,u2,u1,u0],2)$
    [74] T1=time();
    [8.968048,7.705907,1514833,63.359717]
    [75] ["CPU",T1[0]-T0[0],"GC",T1[1]-T0[1]];
    [CPU,6.577163,GC,7.221549]

`References`
  section `cputime`, `tstart`, `tstop`.

Go to the first, previous, next, last section, table of contents.