[REF] web: optimize basic model (improve perfs for most views)

The 'get' method in the basic model is called very often (too often, but
that is another issue).  For a large list with many columns, it can be
quickly be called more than 10k times.

In that function, we had to protect our integrity by performing a deep
clone with $.extend, so noone else can be allowed to change something in
our internal structure.  This is good in theory, but not so good in
practice, as $.extend is a really expensive operation.

Also, we try to have the smallest external API by deleting useless keys.
But instead of keeping a blacklist of private keys, it is simpler to
have a whitelist of public keys.

So, what we do is to explicitely construct the object returned by key,
since we know the types of every values involved.  This is more
explicit, and at the same time, much faster.

Also, we propagate the options for elements of type list.  This is why I
had to change the isFieldSet method.

In a benchmark I just ran, loading and rendering a large list (200 rows,
7 columns) went from about 2.7s to 0.7s.

We still do way too much work, but at least it is much faster...
This commit is contained in:
Géry Debongnie
2017-05-07 22:38:27 +02:00
parent 9d7b421b8c
commit c75680c527
6 changed files with 115 additions and 68 deletions
@@ -1141,7 +1141,7 @@ QUnit.module('basic_fields', {
"graph of first record should be a barchart");
assert.strictEqual(kanban.$('.o_kanban_record:nth(1) .o_graph_linechart').length, 1,
"graph of second record should be a linechart");
var evt = document.createEvent("MouseEvents"); //taken ref from https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/initMouseEvent
evt.initMouseEvent("mouseover", true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
$('.discreteBar')[0].dispatchEvent(evt)