Profiling the Kratos

From KratosWiki
Revision as of 10:56, 27 November 2007 by 147.83.143.248 (Talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Profiling means analyzing the program with respect to the time-consumption of its different functions. Profiling enables one to understand, which parts of the program need (if possible) to be optimized, i.e. give the distribution of the computational effort.

Contents

Section 1

Profiling in Python

Since the standard applications of KRATOS are written in Python, it makes sense to use the Python built-in profiling tools. This can be done by the following include in your application:

  import cProfile

Then, if you want to profile some function (e.g. Solve()) that calls other functions, you have to put:

  cProfile.run('Solve()')

instead of what it was before:

  Solve()

You can also do it from the command prompt by executing your application with the following command line parameters:

  python -m cProfile my_application.py

Note, that the result of this profiling you should better save to a file, so could be better to do directly:

  python -m cProfile myapplication.py >profile_out.txt

This will give you the information about the duration of all the nested PYTHON functions of your application, but no information about the computational effort distribution with one PYTHON function (i.e. if you PYTHON function func1 calls 5 different C++ functions, the information will be given only overall, nothing will be known about how much time each of the 5 C++ functions takes).

For this, it is recommended to split the application in as many PYTHON function as possible, if you would like to have a close look at the part of the program that takes the major amount of computational time.


Section 2

Profiling in C++

This is not recommended, and this section will be filled under request. We believe that PYTHON profiling provides information, sufficient for the optimization.

Personal tools
Categories