The predicate inserts into the user code of File, instrumentation for the collection of the statistics (statistics/2 metric keywords) specified in Statistics. The instrumentation is inserted at clause entry and exit points (i.e. the start, end, fail and redo ports of the conceptual predicate box model) and aggregates the cost for each of the metrics as the program executes. The source code can be annotated with these aggregated results using the result/0 predicate. Additionally, the results may be dumped to a file in a format suitable for offline analysis and graphing.
statprofile/3 should be used for instrumentation profiling of code at a finer granularity than the clause definition. statprofile/3 provides options to prevent the profiling of recursive predicates. It also, provides an option to produce the results for a single execution of a profiled piece of code, in addition to the aggregated results.
The instrumentation profiler places an overhead on the execution of the code undergoing profiling due to the insertion of the profiling code. The sample based profiler is implemented using after events and is therefore less intrusive in its effect on the performance of the executing code than the instrumentation profiler. However, it is used to indicate the trend of resource usage over time of a running program not to attribute specific costs of a statistic to a specific piece of code. The instrumentation based profiler is used to do this.
[eclipse 1]: instprofile:statprofile(queen, [global_stack_used, trail_stack_used]). Yes (0.06s cpu)