Note: Compiling with -p produces a bcode file that will run somewhat more slowly than usual. Do not make -p the default for compilation. It is possible to get function call counting (but not function timing) for a program that was not compiled with -p if the -syms flag was given to lcd for the final stage of the compilation; in this case the program will run at normal speed.
bci_profile_onRun your program as normal. When it has finished, or it has run for long enough, execute the command
bci_profile_offThis will write the profile.out file in the current directory.
Alternatively you can use an li command line such as
li prog.bcode profrunThe profrun module simply enables profiling, runs the program, and then disables it.
The information is displayed in the following sections:
In each case, the filename, line number and identifier is given. For identifiers declared at the top level in any file it is not possible to report the filename and line number; instead these identifiers are listed as "global". In the functions, expressions, types and val/var functions sections the number of calls to that entity is listed. For function times the total time spent in each function in sections and the percentage of the total execution time is listed. This time excludes time spent in children that have their own function time entries, but includes time spent in children that do not have entries, such as standard library routines.
Enabling optimisation will cause statistics for some library routines to be incaccurate, but does not affect the validity of results for user functions.