HP Caliper Advisor Rule Writer Guide
Analysis and Printing Steps
After all the preprocessing has been done, the Advisor does its actual analysis work.
The main processing loop does the following for every selected analysis object (in
alphabetic order):
1. A new analysis report is started and the descriptive section is printed.
2. All compiled rule functions are called, passing only the current object being
analyzed. Each rule function retrieves the object’s performance data that it needs,
makes decisions about a possible performance problem, and, if appropriate,
generates one or more advice messages.
The rules are autonomous and have no knowledge of each other or about any
other object(s) to be analyzed. Due to the seemingly random way that Python
maintains dictionaries, the rule functions are not executed in the strict order they
occur in the rule files. Because of the independent nature of rules, this doesn't
cause a problem, however.
3. All rule-generated advice is filtered, sorted (with the most important advice first),
and printed.
The advice that is printed depends on these command-line options specified by
the user:
• --advice-classes
• --advice-details
• --advice-cutoff
4. The Advisor closes all of the databases, cleans up after itself, and terminates.
Rule Files: Syntax and Concepts
The first line of every rule file must be of this form:
# rules What these rules deal with
where # rules is mandatory and the rest of the line is optional.
The Advisor validates a rule file by checking that the first line begins with # rules.
The remainder of the line, if it exists, is a brief description of the rule file and is printed
in the descriptive section of an Advisor report for identification purposes. The remainder
of the file can be a mixture of rule functions, helper functions, and include statements.
Rule functions are all named rule_* (where the * is replaced with the name of the
rule) and have only one parameter: the object to be analyzed. Rule functions are directly
invoked by the Advisor.
A helper function is a function that is called only by a rule function or another helper
function. A helper function can have any name and any number of parameters.
Rule and helper functions are Python function definitions of the following form. Note
that Python uses indenting in place of {} to group statements:
Rule Files: Syntax and Concepts 29