VisualAge C++ Tips

Use the Performance Analyzer
The Performance Analyzer is a marvellous tool for analysing the behaviour and performance of your applications. You create a trace file by running it along with your application, and then you analyse the data by looking at it with the Analyzer's 5 views: One of the most interesting is the Dynamic Call Graph:
 * What Is It?
 * Call Nesting Diagram
 * Dynamic Call Graph
 * Execution Density Diagram
 * Statistics Diagram
 * Time Line Diagram

[Screen capture of Performance Analyzer Call Graph]

The nodes (rectangles) represent functions and the arcs (lines) represent calls.

The size, shape, and colour of the nodes gives information about the time spent in each function! Gray, blue, yellow, and red colours are used for functions which use up to 1/8, 1/4, 1/2, and the maximum of the total execution time, respectively. The height of a node depicts the execution time of a function, and the width depicts the active time (the time on the stack, even while a callee is running).

The arcs are similarly coloured to represent the frequency of calls.

If you're using the Workframe, enabling the Analyzer is as simple as clicking on the Build Smarts button on the toolbar, and selecting the Analyzer checkbox on the dialog that appears:
 * How Is It Enabled?



Figure 2: Build Smarts Dialog Box

Then click on Build to rebuild your application with the Analyzer enabled. To start the Analyzer, choose "Analyze" from the Project menu.

Use the Debug Memory Management Facilities
Debugging versions of malloc, calloc, realloc, free, new and delete
 * What are they?


 * What do they offer?
 * Information about memory you failed to free
 * Notice that you are freeing already freed memory
 * Notice that you wrote over freed memory


 * How do you enable them?:Use the /Tm VisualAge C++ compiler option

Compile this program with /Tm. Run it with the w command line option (no slash) to write over memory which has already been freed. Notice that it catches the error. Run it again with the f command line option and watch it detect your freeing the same object twice.
 * Sample Program

Compile it again without /Tm and run it the same two ways. The memory management offenses are undetected.

Use the IBM Open Class User Interface Library
Using the IBM Open Class User Interface Libraries (UICL, ICLUI) speeds application development. Let's compare some native PM code with the equivalent library code.

Use the Open Class User Interface Exceptions
This tip demonstrates 4 handy Open Class macros which help you throw exceptions to report errors.


 * Sample Program

For best results, run it with the run.cmd contained in the zip file (throwdem.zip, 5,279 bytes), and make sure you have pmprintf.exe in the path. You can run it without pmprintf, but if you do, then do not use run.cmd. Instead, type the following commands: set ICLUI TRACETO=STDERR throwdem 2>err When the program starts, choose one of the menu options, and then exit the program and look into the err file.
 * Running the Program

This program is designed to be self-explanatory.
 * Source Code Listing