Software Review — APAT: First Impressions
Vector 1:2, page 44
Transcribed from the printed issue; not yet reviewed. Read it in the PDF of the issue, page 44
IBM has attempted to provide a set of tools to increase the efficiency and ease the maintenance of APL code. The documentation for these tools is adequate but there are errors in the code which need correction before use.
The tools are mostly flexible. All functions are unlocked so the logic used for each tool can be examined and tailored to meet particular requirements. Results are either returned as an APL variable or the name of a print function is provided which can be amended to redirect the output.
Efficiency¶
Execution times of functions, lines or expressions can be measured using ‘PARETO’. The CPU time used in each function is calculated; the analysis is more difficult on large systems as one extra function is added for every function monitored. Our own approach to split CPU usage between functions was to count the number of times various lines were executed. This is less informative than timing each function but takes less CPU time itself, so it is more suitable for a long term check. ‘PARETO’ would therefore only be useful for a short term check.
Proposed amendments can be compared using ‘EXTIMER’ to evaluate the saving made; each function is repeated until the variation in CPU usage is within acceptable limits. Our ‘TIME’ function is a simple version of ‘EXTIMER’ — it executes the function only once and does not compare the execution times of different functions.
Once the areas where most CPU time is used have been ascertained, further effort can be concentrated on those functions. If necessary the CPU usage can be calculated for each line separately. (An extra function is created for every monitored line so it must be restricted to a few functions only; this could be rewritten more efficiently to avoid excessive function calls). CPU time required by functions called during executin is not included unless the called function is locked or the modifications made to the called functions are reversed. Our ‘CLOCKIN’ function can be used to monitor only the CPU usage generated by each line.
In addition to execution time, the available workspace required by a function or expression will be calculated by ‘IRONMAID’. The point at which maximum usage occurs is identified. In a programme running with restricted workspace,this highlights the worst areas, which will then allow the best balance between CPU time and workspace to be found.
Maintenance¶
There are several tools which ease maintenance of APL code
‘CONSTRUE’ executes an expression or line of a function in parts. Complicated lines of code are simplified by showing the order of execution of each line and intermediary results. Understanding code written by someone else is much easier using this tool.
‘MONITOR’ shows the number of time each line of a function has been executed. A function is added to the end of each line in a way that does not affect execution. This function could be rewritten to record any aspect of the monitored function that is useful. The option to stop monitoring does not return it to its original form so it would be safer to copy the function from another workspace and erase the monitor variables separately.
‘BMONITOR’ shows every branch within specified functions in order.
‘VMONITOR’ displays all values assigned to specified variables within specified functions.
The last three of these would be particularly useful for identifying the point at which an error occurs.
In the past, efficiency has been checked using a mixture of formal and informal methods. The IBM set of tools extends the range of checks and makes them easier to use and interpret. Whilst there has not been sufficient need to create these tools for ourselves, now that they are available they will prove useful.