summaryrefslogtreecommitdiff
path: root/odoo/tools
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-11-22 17:52:57 +0100
committerChristophe Simonis <chs@odoo.com>2018-11-22 17:52:57 +0100
commitb09f624f20781d65baf2060df40383898e6f86e5 (patch)
treefbaf29a0fca1ce63e616698717435fd1a8413921 /odoo/tools
parentbab2a191d292737d1c2bc6b1650a1581614b0cc1 (diff)
parent263b388c5045bebc77cc27847f7500784f63c7f5 (diff)
[MERGE] forward port branch 11.0 up to 263b388c504
Diffstat (limited to 'odoo/tools')
-rw-r--r--odoo/tools/cache.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/odoo/tools/cache.py b/odoo/tools/cache.py
index a4f49831d6c..052f89545a2 100644
--- a/odoo/tools/cache.py
+++ b/odoo/tools/cache.py
@@ -205,16 +205,22 @@ def log_ormcache_stats(sig=None, frame=None):
me = threading.currentThread()
me_dbname = getattr(me, 'dbname', 'n/a')
- entries = defaultdict(int)
- for dbname, reg in Registry.registries.items():
- for key in reg.cache:
- entries[(dbname,) + key[:2]] += 1
- for key, count in sorted(entries.items()):
- dbname, model_name, method = key
+
+ for dbname, reg in sorted(Registry.registries.items()):
+ # set logger prefix to dbname
me.dbname = dbname
- stat = STAT[key]
- _logger.info("%6d entries, %6d hit, %6d miss, %6d err, %4.1f%% ratio, for %s.%s",
- count, stat.hit, stat.miss, stat.err, stat.ratio, model_name, method.__name__)
+ entries = defaultdict(int)
+ # beware: we use .keys() on purpose here (reg.cache is not a real dict)
+ for key in reg.cache.keys():
+ entries[key[:2]] += 1
+ # show entries sorted by model name, method name
+ for key in sorted(entries, key=lambda key: (key[0], key[1].__name__)):
+ model, method = key
+ stat = STAT[(dbname, model, method)]
+ _logger.info(
+ "%6d entries, %6d hit, %6d miss, %6d err, %4.1f%% ratio, for %s.%s",
+ entries[key], stat.hit, stat.miss, stat.err, stat.ratio, model, method.__name__,
+ )
me.dbname = me_dbname