[IMP] base: add test for routing_map perfs
This test will help making stats on routing_map generation performances This will help to mesure the time for the main `None` routing map as well as for website1, the idea being that it would be possible to mutualize a part of this computation between routing maps. closes odoo/odoo#120591 X-original-commit: 6646fa7e2ef64e5f060bf38b0d85bf1188d79e4f Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user