The Ciao profiler provides a high-level, flexible way to mark a predicate (or a literal) for profiling. This is done by using declarations to indicate if a program element must be instrumented or not.
The profiler module provides predicates and declarations to automatically handle profiling of the program to measure the time spent by predicates (or literals), as well as other cumulative statistics such as number of calls. It is made up of two parts: one implemented at the Ciao level, and another one implemented in C.
By default, if the user does not specify anything, no predicate inside the module will be instrumented as cost center for profiling. The use of at least one declaration saying that a specific predicate must be instrumented overrides this behavior.
The declaration is as follows:
:- cost_center pred1/Arity1, ... predN/ArityN.
By default the engine hooks of all defined cost center are active. The declaration:
will deactivate them.
Another useful declaration makes possible to indicate that a given predicate is not going to be instrumented as cost center:
:- no_cost_center pred1/Arity1, ... predN/ArityN.
where pred1/Arity1, ..., predN/ArityN are the predicates that will not be instrumented as cost centers. There are two options (as in the previous case): write one assertion for each predicate or declare more than one predicate (separated by commas or in a list) in only one assertion.
The following assertions define the behavior of all the predicates of the module:
They specify respectively that all the predicates in the module will be instrumented as cost centers and that no predicate in the module will be instrumented as cost center. In the first assertion the engine hooks of all defined cost centers are active. The declaration :- all_cost_center(nohooks). will deactivate them.
Cost centers can be also defined at literal level replacing the literal by the declaration:
:- cost_center(name_cc, literal)
where literal is the program literal and name_cc is the name of its associated cost center. At predicate level the name of both cost center and predicate are equal.