Profiling COBOL

Profiling options

Profiling is enabled with the -fprof flag while compiling a COBOL module. Only modules that have been compiled with profiling enabled can be later profiled.

Then executing your program with COB_PROF_ENABLE=1 will automatically profile the module(s) and generate a CSV result file. Note that physical CANCEL is disabled when profiling is enabled, because some profiling information in the module needs to remain available until the end of the program.

By default, this file is called cob-prof-<program-id>-<pid>.csv, but this name can be configured using COB_PROF_FILE.

Some environment variables (and the corresponding options in the runtime configuration) can be used to tune the behavior of profiling during execution: COB_PROF_FILE, COB_PROF_ENABLE and COB_PROF_MAX_DEPTH, COB_PROF_FORMAT see Runtime Configuration for more information.

Profiling results

By default, the generated CSV file has 8 columns for each line (it can be customized with the COB_PROF_FORMAT environment/runtime configuration):

program-id

The program identifier of the module.

section

The name of the section. The time of a section is not computed directly, but as the sum of the time spent in its paragraphs.

paragraph

The name of the paragraph. If a section has no paragraph, or does not start with a paragraph, a default paragraph called MAIN PARAGRAPH is created.

entry

The name of the entry for ENTRY statements, or the name of the target for CALL statements. No time is associated with ENTRY statements, as the time is directly included in the including paragraph. However, the number of calls is still recorded.

location

The file and line number of the corresponding entry point (section or paragraph)

kind

The kind is either PROGRAM, SECTION, PARAGRAPH, CALL or ENTRY.

time-ns

The time spent in the module/section/paragraph/call in nanoseconds

time

The time spent in the module/section/paragraph/call in a human readable form (currently, the time in seconds and milliseconds)

ncalls

The number of calls to this section/paragraph