Obtaining accumulated processor time
The TIMEUSED macro enables you to record execution times and to measure performance. TIMEUSED returns the amount of processor or vector time a task has used since being created (attached).
Example of measuring performance with the TIMEUSED macro
Use TIMEUSED to measure the efficiency of a routine
or other piece of code. If you need to sort data, you may now code
several different sorting algorithms, and then test each one. The
logic for a test of one algorithm might look like this:
- Issue TIMEUSED
- Save old time
- Run sort algorithm
- Issue TIMEUSED
- Save new time
- Calculate time used (new time - old time)
- Issue a WTO with the time used and the algorithm used.
After running this test scenario for all of the algorithms available, you can determine which algorithm has the best performance.
Note: The
processor time provided by TIMEUSED does not include any activity
for execution in SRB mode (such as I/O interrupt processing).