Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(perf): hydrateComponent perf tests #2663

Merged
merged 4 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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 { renderComponent } from '@lwc/engine-server';
import { hydrateComponent } from '@lwc/engine-dom';

import Table from 'perf-benchmarks-components/dist/server/benchmark/cardComponent/cardComponent.js';
import Store from 'perf-benchmarks-components/dist/server/benchmark/store/store.js';

import TableClient from 'perf-benchmarks-components/dist/dom/benchmark/cardComponent/cardComponent.js';
import { benchmark, run, before } from '../../utils/benchmark-framework.js';
import { insertComponent } from '../../utils/utils';

benchmark(`benchmark-table/hydrate/1k`, () => {
let tableElement;
let props;

before(async () => {
const store = new Store();
store.run();

props = {
title: 'table hydrate 1k',
rows: store.data,
};

const ssrHtml = renderComponent('benchmark-table', Table, props);

const fragment = new DOMParser().parseFromString(ssrHtml, 'text/html', {
includeShadowRoots: true,
});

tableElement = fragment.querySelector('benchmark-table');

await insertComponent(tableElement);
});

run(() => {
hydrateComponent(tableElement, TableClient, props);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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 { renderComponent } from '@lwc/engine-server';
import { hydrateComponent } from '@lwc/engine-dom';

import Table from 'perf-benchmarks-components/dist/server/benchmark/tableComponent/tableComponent.js';
import TableClient from 'perf-benchmarks-components/dist/dom/benchmark/tableComponent/tableComponent.js';

import Store from 'perf-benchmarks-components/dist/server/benchmark/store/store.js';
import { benchmark, run, before } from '../../utils/benchmark-framework.js';
import { insertComponent } from '../../utils/utils';

benchmark(`benchmark-table-component/hydrate/1k`, () => {
let props;
let tableElement;

before(async () => {
const store = new Store();
store.run();

props = {
rows: store.data,
};

const ssrHtml = renderComponent('benchmark-table', Table, props);

const fragment = new DOMParser().parseFromString(ssrHtml, 'text/html', {
includeShadowRoots: true,
});

tableElement = fragment.querySelector('benchmark-table');

await insertComponent(tableElement);
});

run(() => {
hydrateComponent(tableElement, TableClient, props);
});
});