Profiler (programming)

from Wikipedia, the free encyclopedia

As Profiler are programming tools referred to the run-time behavior analysis software. There are different problem areas in software development that are triggered by inefficient programming. A profiler helps the developer to identify problem areas by analyzing and comparing running programs . From this one can derive measures for the structural and algorithmic improvement of the source code.

Areas of profiling

Measure speed

The most common use of a profiler is to count and measure the calls and runs of functions . This enables the programmer to find out where optimization of the program is worthwhile. Optimizing functions that are not used frequently is not particularly beneficial for the overall performance of the program and usually makes it difficult to maintain the source code. That is why the main focus is on functions that are called often and that take up a lot of time in total.

Memory usage

Another aspect is the tracking of memory usage by a program. The profiler is intended to help optimize the use and consumption of working memory and, if necessary, to uncover programming errors that prevent unused memory areas from being released ( memory leak ).

Concurrency

Modern profilers offer the option of displaying concurrent processes ( threads ) in their life cycle graphically (for example as a bar or network diagram ). This visual presentation is intended to help a programmer to interpret the runtime behavior of concurrent processes better and errors due to deadlock ( deadlock uncover).

Technical aspects of profiling

Profiling a program itself usually affects the application to be analyzed. Typically, the profiler itself slows down execution. In addition, a very large amount of data is generated when analyzing large programs. There are different techniques in profiling that have different degrees of such an influence, possibly with a loss of analytical accuracy. In addition, the profilers make it possible to determine which program parts should be analyzed at all.

statistical evaluation

By means of the statistical evaluation, the program analysis is not subjected to a measurement exactly with every program command. Rather, the running time is measured in a specific time cycle. This process is also called sampling. The profiler thus intervenes in the program sequence at certain clock cycle intervals and thus determines on a random basis which program parts have been called since the last cycle. A statistical mean value is calculated from this, which is included in the result of the analysis.

The current program is not changed during the statistical evaluation.

instrumentation

With the instrumentation , certain (or even all) program sections (for example during runtime) are extended with analysis code by the user. This means that interrupts or program code are inserted into the program, which signal the profiler during the program run that the section is currently being processed. The time between the calls to the analysis points (as well as the storage behavior as a difference to a previous run) can flow into the result of the analysis as runtime values.

So the instrumentation changes the program to calculate the analysis data.

There are different types of instrumentation:

  • Manual instrumentation by expanding the source code with commands that calculate the runtime (e.g. with the programming interface of the Application Response Measurement standard).
  • Programs that have been expanded by compiler options, which are then given profiler marks.
  • Subsequent changes to compiled programs by inserting marks.
  • Runtime instrumentation: The saved program remains untouched. The profiler marks are added in memory before running.

Profile images

The aim of a program analysis is an efficient runtime behavior of the application. Many profilers allow the collected analysis data to be saved and compared so that a comparison can also be made objectively. In this way, program changes can be compared and evaluated in terms of their runtime behavior. The profilers usually show the comparison values ​​in relative terms as percentages or as absolute values. However, since a profiler itself always affects the runtime behavior during the analysis, such comparison values ​​must not be viewed as an actual change.

software

  • gprof
  • PerfTools
  • The process scheduler Slurm also has profiling options.
  • ProDelphi is a profiler for Delphi (Object Pascal)
  • ProLaza is a profiler for Lazarus (Object Pascal)
  • CODESYS Profiler was developed for IEC 61131-3 code (e.g. structured text) with CODESYS

See also

Individual evidence

  1. gcc / g ++ -finstrument-functions compiler option gcc.gnu.org, accessed January 22, 2016.