![]() ![]() |
|
jprofThe jBASE profiling tools jprof enables developers to analyze applications to determine potential bottlenecks or trouble spots within the application code. By default, no profiling is done in the program. Programs do not have to be compiled in any special manner to enable profiling for that program. All that is required is that the programs were not compiled with optimization, as this discards the debug information which is required for profiling. The mechanism works by receiving a signal at every clock tick and keeping note of where the program was when the signal arrived. Thus, for the profiling to be accurate, the application must be run for a relatively long time. It will not show particularly good results if, for example, a program executes in less than a second. Several minutes or longer is preferred. Currently profiling is available only with jBASE on Unix (including Linux) platforms.
ENABLING PROFILINGProfiling can either be enabled using the -JP option, which only profiles the root process, or via the JBCPROFILE environment variable, which profiles the root process as well as all EXECUTEd processes.
This command generates a profiling file called jprof_n in the current directory where where n is the port number. Only MAINPROG and any CALLed subroutines are profiled, any EXECUTEd programs will not be profiled. However, if the CPU time spent executing the actual EXECUTE statement is significant, that line will be included in the profiling statistics. When the application stops or chains to another program profiling is terminated.
This command generates a different profiling file for each process executed in the form jprof_pid_n, where pid is the process id and n is an incrementing number starting at 0. The profiling file generated will only contain information about user CPU time. The time spent in system calls, file I/O, and lines which do not accumulate more than a clock tick are not included in the profiling statistics.
PROFILE REPORTINGThe jprof command is used to provide profile analysis of the jprof files generated by a program executed with the -JP option. Called as:
EXAMPLE OF PROFILINGImagine the source "test1.b" below has been edited into file BP, where BP is a directory. Notice the INCLUDE of another source file "test2.b".
The program can be created normally with the following command:
or it can be created with BASIC and CATALOG:
By default, when the program is run, no profiling will take place. Now run the program with the -JP switch to create a file "jprof":
We can now examine the profile file with the "jprof" command, using the -f option to generate optional source code listings from the file BP.
PROFILE REPORT
The -i option would sort the output with incrementing Ticks counts. The -n option would additionally sort it by file name, so the "test1.b" entries will be displayed separately to the "test2.b" entries. |