Profiling (computer programming)

As Profiler programming tools are called who analyze the runtime behavior of software. There are several problem areas in software development, which are caused by inefficient programming. A profiler helps the developers by analyzing and comparing of running programs to uncover the problem areas. From this we can derive measures for structural and algorithmic improvement in the source code.

  • 2.1 Statistical analysis
  • 2.2 Instrumentation

Areas of the profiling

Measurement of speed

The most common use of a profiler is the counting and measuring of the calls and passes of functions. This allows the programmer to figure out where it is worth to optimize the program. Optimization of functions that are not used frequently, the overall performance of the program is not particularly beneficial and complicates the maintainability of the control of the source code. Therefore, the main focus will be on functions that are called many times and in the sum of the calls require a lot of time.

Memory usage

Another aspect is the tracking of memory usage by a program. The profiler will help to optimize the use and consumption of memory and possibly detect errors in programming, will not release the unused memory areas ( memory leak).

Concurrency

Modern profiler offer the opportunity to graphically (eg as a bar chart or network diagram ) to represent concurrent processes (threads) in their life cycle. This visual presentation is intended to help a programmer to better interpret the runtime behavior of concurrent processes and detect errors due to deadlock ( deadlock ).

Technical aspects of the profiling

Profiling a program itself usually causes influencing the analyzed application. Typically, the profiler itself slows the speed of execution. Furthermore, in analyzes of large programs, a very large amount of data. There are different techniques for profiling, the different degrees of mint such an influence, possibly with loss of analysis precision. In addition, the Profiler enable it to determine which parts of the program to be analyzed at all.

Statistical analysis

By means of statistical analysis, the program analysis is not exactly subjected to each program instruction a measurement. There the term is rather measured in a certain time cycle. This procedure is also called sampling. The profiler uses at set intervals in clock cycles the program flow and determines so random, which parts of the program have been called since the last cycle. From a statistical mean is calculated, the flows to the result of the analysis.

For the statistical analysis the current program is not changed.

Instrumentation

With the instrumentation from the user specific ( or all ) be expanded program sections (for example, during the term ) with analysis code. That is, it will be inserted into the interrupt program brands (interrupts ) or program code, which signal to the profiler during program execution, that the section is currently being processed. The time between calls to the analysis points (as well as the saving behavior as a differential to a previous run) can be included as a term in the result of the analysis again.

Thus, the instrumentation of the modified program in order to calculate the analytical data.

There are various types of instrumentation:

  • Manual instrumentation by extending the source code to commands that calculate the duration (eg with the programming interface of the Application Response Measurement Standards).
  • Through compiler options Advanced programs, thereby obtaining the profiler brands.
  • Subsequent modification of the compiled programs by inserting brands.
  • Runtime instrumentation: where the stored program remains untouched. The profiler marks are added before running in memory.

Profile images

Goal of program analysis is an efficient runtime behavior of the application. Thus, a comparison also succeed objectively, allowing many Profiler to store the collected data analysis and compare. Thus, program changes can be compared and evaluated in their runtime behavior. The profiler show the comparative values ​​usually at relatively as percentages or as absolute values ​​. But as always affected a profiler runtime behavior during the analysis itself, such a comparison values ​​must not be regarded as actual change.

Software

  • Gprof
  • PerfTools
  • The process scheduler Slurm also has profiling options.
662106
de