Commit Graph
3 Commits
Author SHA1 Message Date
Christophe Matthieu b04bf31e29 [FIX] odoo profiler: Calculation error for loops
The previous line in a loop calculates the number of queries made until
the end of the loop. This causes the number of queries to be counted
twice.
Don't blacklist the entry point method.
Check the methods called from a blacklisted method.
2017-08-09 14:05:07 +02:00
Christophe Simonis 2b7179380a [FIX] tools: avoid defining unused variable using python2 only syntax 2017-08-07 15:02:56 +02:00
Christophe Matthieu 8fa7c68ca8 [IMP] tools: add a profiler for odoo performance analysis
Use ``profile`` to decorate an entry point method.
If ``profile`` is used without params, log as shallow mode else log
all methods for all odoo models by applying the optional filters.

:param whitelist: None or list of model names to display in the log
                 (Default: None)
:type whitelist: list or None
:param files: None or list of filenames to display in the log
                (Default: None)
:type files: list or None
:param list blacklist: list model names to remove from the log
                (Default: remove non odoo model from the log: [None])
:param int minimum_time: minimum time (ms) to display a method
                (Default: 0)
:param int minimum_queries: minimum sql queries to display a method
                (Default: 0)

.. code-block:: python

  from odoo.tools.profiler import profile

  class SaleOrder(models.Model):
    ...

    @api.model
    @profile                    # log only this create method
    def create(self, vals):
    ...
    @api.multi
    @profile()                  # log all methods for all odoo models
    def unlink(self):
    ...
    @profile(whitelist=['sale.order', 'ir.model.data'])
    def action_quotation_send(self):
    ...
    @profile(files=['/home/openerp/odoo/odoo/addons/sale/models/sale.py'])
    def write(self):
    ...

NB: The use of the profiler modifies the execution time
2017-07-26 15:02:59 +02:00