How to Profile (Measure Time Consumption)
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.
You have to be sure that the package python- profile is actually installed in your pc. Control it in the system package manager and eventually install it! This operation will provide the packages
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:
Then, if you want to profile some function (e.g. Solve()) that calls other functions, you have to put:
instead of what it was before:
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.
For more details see http://docs.python.org/lib/profile.html