/
wc-clear-1k.benchmark.js
39 lines (32 loc) · 1.25 KB
/
wc-clear-1k.benchmark.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { buildCustomElementConstructor } from 'lwc';
import Table from 'benchmark/tableComponent';
import Row from 'benchmark/tableComponentRow';
import Store from '../../tableStore';
import { insertTableComponent, destroyTableComponent } from '../../utils';
customElements.define('benchmark-table-component', buildCustomElementConstructor(Table));
// the row can be optionally defined, but this benchmark always do it so we know how costly it is.
customElements.define('benchmark-table-component-row', buildCustomElementConstructor(Row));
benchmark(`benchmark-table-wc/clear/1k`, () => {
let tableElement;
let store;
before(async () => {
tableElement = document.createElement('benchmark-table-component');
await insertTableComponent(tableElement);
store = new Store();
store.run();
// eslint-disable-next-line require-atomic-updates
tableElement.rows = store.data;
});
run(() => {
tableElement.rows = [];
});
after(() => {
destroyTableComponent(tableElement);
});
});