diff --git a/odoo/addons/base/tests/__init__.py b/odoo/addons/base/tests/__init__.py index b47f40957e1..49b05903c9b 100644 --- a/odoo/addons/base/tests/__init__.py +++ b/odoo/addons/base/tests/__init__.py @@ -20,6 +20,7 @@ from . import test_ir_actions from . import test_ir_attachment from . import test_ir_cron from . import test_ir_filters +from . import test_ir_http from . import test_ir_mail_server from . import test_ir_model from . import test_ir_sequence diff --git a/odoo/addons/base/tests/test_ir_http.py b/odoo/addons/base/tests/test_ir_http.py new file mode 100644 index 00000000000..692302c2632 --- /dev/null +++ b/odoo/addons/base/tests/test_ir_http.py @@ -0,0 +1,30 @@ +import logging +import re +import time + +from odoo.tests import tagged +from odoo.tests.common import TransactionCase + +_logger = logging.getLogger(__name__) + + +@tagged('-at_install', 'post_install') +class TestIrHttpPerformances(TransactionCase): + + def test_routing_map_performance(self): + self.env['ir.http']._clear_routing_map() + # if the routing map was already generated it is possible that some compiled regex are in cache. + # we want to mesure the cold state, when the worker just spawned, we need to empty the re cache + re._cache.clear() + + self.env['ir.http']._clear_routing_map() + start = time.time() + self.env['ir.http'].routing_map() + duration = time.time() - start + _logger.info('Routing map web generated in %.3fs', duration) + + # generate the routing map of another website, to check if we can benefit from anything computed by the previous routing map + start = time.time() + self.env['ir.http'].routing_map(key=1) + duration = time.time() - start + _logger.info('Routing map website1 generated in %.3fs', duration)