How to do it...

Odoo's profiler is available at odoo/tools/profiler.py. In order to use the profiler in your code, import it into the file:

from odoo.tools.profiler import profile

After importing it, you can use the profile decorator on the methods. To profile a particular method, you need to add the profile decorator on it. Take a look at the following example. We put the profile decorator on the make_available method:

    @profile
def make_available(self):
if self.state != 'lost':
self.write({'state': 'available'})
return True

So, when this method is called, it will print the full statistics in the logs:

calls    queries   ms
library.book ------------------------ /Users/pga/odoo/test/my_library/models/library_book.py, 24

1 0 0.01 @profile
def make_available(self):
1 3 12.81 if self.state != 'lost':
1 7 20.55 self.write({'state': 'available'})
1 0 0.01 return True

Total:
1 10 33.39
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset