2. Overview
Writing programs is fun, but making them fast can be a pain. Python programs
are no exception to that, but the basic profiling toolchain is actually not that
complicated to use.
Profiling application code helps you to identify time/space issues in the
application. You will get answers for typical questions like how long each
function/method takes to execute? how good is the application at memory
consumption etc.
There are multiple tools and libraries available for profiling in python world.
6. cProfile:
Since Python 2.5, Python provides a C module called cProfile
which has a reasonable overhead and offers a good enough
feature set. The basic usage goes down to:
10. cProfile integration for Odoo
Use odoo-profiler module from Vauxoo : https://github.com/Vauxoo/odoo-profiler
How to use it???
After installation, a player is add on the header bar, with these items:
- Start profiling
- Stop profiling
- Download stats: download stats file
15. Let’s do little modification on profiler module
profiler/controller/main.py
On dump function, change this line:
From
stats_path = os.path.join(dump_dir, ‘%s.stats’ % filename)
To
stats_path = os.path.join(dump_dir, ‘%s.cprof’ % filename)
16. How to use it?
run this command:
And let’s see the magic...