next up previous index
Next: The Built-in Predicates Up: Using the Statistics Previous: Selective Collection

Obtaining mode information

    The global statistics-flag can take another value called mode. This has the same effect as all, but in addition there is information collected about the actual arguments of predicate calls. The arguments are tested for being instantiated and for groundness. This information is helpful to provide mode declarations for a program. The results are displayed by the print_modes/0 built-in in the form of a mode declaration summarising the information that could be extracted from the predicate calls executed. The output is in the form of a mode declaration that can be read in and executed.

[eclipse 1]: set_flag(statistics,mode).

yes.
[eclipse 2]: debug(go_qsort).
Start debugging - leap mode
Stop debugging.

yes.
[eclipse 3]: print_modes.
:- mode
    list50(-),
    qsort(++, -, ++),
    partition(++, ++, -, -).

yes.
Note that these modes are not the result of a program analysis. They just indicate what arguments occurred in the sample run of the program. Hence it may well be that running the program with different data produces a different mode statistics.

If a procedure has already an explicit mode declaration, the modes returned by the mode statistics will not be more restrictive than the declaration, e.g. if a declaration

:- mode p(+).
exists and p/1 is called with a ground argument only, the generated mode will be + rather than ++.



next up previous index
Next: The Built-in Predicates Up: Using the Statistics Previous: Selective Collection



Micha Meier
Mon Mar 4 12:11:45 MET 1996