| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (3 out of 4)

How to Measure Performance

To optimize the performance of your KB, you must have an accurate picture of how G2 allocates time to different tasks. Do not rely on intuition; usually, only a handful of procedures account for the bulk of the work in an application. Bear in mind that no matter how much you speed up a procedure that takes only 1% of the CPU, your net improvement will always be less than 1%.


Target performance optimizations precisely at the elements of your KB that are computational bottlenecks. Optimizing non-bottleneck procedures will have little effect on overall performance.

The G2 profiler is the only accurate way to determine what elements of your KB are consuming computational resources. We recommend that you include the module profile.kb, which is distributed with G2, in your development environment. This KB provides a reporting facility that gives you the time spent in each procedure, function, or rule, as well as information on the number of calls and average time for each.

You can also measure performance by inserting timing statements directly into the procedures you wish to benchmark. This technique is convenient if you want to measure the aggregate time spent in a large calling tree of procedures. In this approach, you measure the difference between the current subsecond real time at the beginning and end of the computation. This approach is somewhat less convenient than using the profiler, which gives more information without requiring code modification. Also, this approach cannot handle wait states because time for other threads are included in the benchmark.

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (3 out of 4)

Copyright © 1997 Gensym Corporation, Inc.