-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add benchmark for light dom slots (#4808)
- Loading branch information
Showing
9 changed files
with
214 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
.../@lwc/perf-benchmarks-components/src/benchmark/cardComponentLight/cardComponentLight.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!-- | ||
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 | ||
--> | ||
<template lwc:render-mode="light"> | ||
<h1>{title}</h1> | ||
<template for:each={rows} for:item="row"> | ||
<benchmark-table-component-row-light | ||
key={row.id} | ||
class={row.className} | ||
row={row} | ||
> | ||
</benchmark-table-component-row-light> | ||
</template> | ||
<div> | ||
<slot></slot> | ||
</div> | ||
</template> |
14 changes: 14 additions & 0 deletions
14
...es/@lwc/perf-benchmarks-components/src/benchmark/cardComponentLight/cardComponentLight.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* 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 { LightningElement, api } from 'lwc'; | ||
|
||
export default class CardComponentLight extends LightningElement { | ||
static renderMode = 'light'; | ||
@api title; | ||
// Note: This is only to give volume to the rehydration process. | ||
@api rows; | ||
} |
21 changes: 21 additions & 0 deletions
21
...-benchmarks-components/src/benchmark/slotUsageComponentLight/slotUsageComponentLight.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!-- | ||
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 | ||
--> | ||
<template lwc:render-mode="light"> | ||
<h1>{componentContent}</h1> | ||
<benchmark-card-component-light title={titleOfComponentWithSlot} rows={rowsOfComponentWithSlot}> | ||
|
||
<template for:each={rowsOfSlottedContent} for:item="row"> | ||
<benchmark-table-component-row-light | ||
key={row.id} | ||
class={row.className} | ||
row={row} | ||
> | ||
</benchmark-table-component-row-light> | ||
</template> | ||
|
||
</benchmark-card-component-light> | ||
</template> |
15 changes: 15 additions & 0 deletions
15
...rf-benchmarks-components/src/benchmark/slotUsageComponentLight/slotUsageComponentLight.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* 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 { LightningElement, api } from 'lwc'; | ||
|
||
export default class SlotUsageComponentLight extends LightningElement { | ||
static renderMode = 'light'; | ||
@api componentContent; | ||
@api rowsOfSlottedContent; | ||
@api titleOfComponentWithSlot; | ||
@api rowsOfComponentWithSlot; | ||
} |
11 changes: 11 additions & 0 deletions
11
...rf-benchmarks-components/src/benchmark/tableComponentRowLight/tableComponentRowLight.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!-- | ||
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 | ||
--> | ||
<template lwc:render-mode="light"> | ||
<span>{row.id}</span> | ||
<div><a onclick={handleSelect} data-id={row.id}>{row.label}</a></div> | ||
<div><a onclick={handleRemove} data-id={row.id}>Remove</a></div> | ||
</template> |
20 changes: 20 additions & 0 deletions
20
...perf-benchmarks-components/src/benchmark/tableComponentRowLight/tableComponentRowLight.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* 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 { LightningElement, api } from 'lwc'; | ||
|
||
export default class TableComponentRowLight extends LightningElement { | ||
static renderMode = 'light'; | ||
@api row; | ||
|
||
handleSelect() { | ||
this.dispatchEvent(new CustomEvent('select')); | ||
} | ||
|
||
handleRemove() { | ||
this.dispatchEvent(new CustomEvent('remove')); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
..._benchmarks__/engine-dom/benchmark-slot-light/light-slot-create-container-5k.benchmark.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* 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 { createElement } from '@lwc/engine-dom'; | ||
|
||
import SlotUsage from '@lwc/perf-benchmarks-components/dist/dom/benchmark/slotUsageComponentLight/slotUsageComponentLight.js'; | ||
import Store from '@lwc/perf-benchmarks-components/dist/dom/benchmark/store/store.js'; | ||
import { insertComponent, destroyComponent } from '../../../utils/utils.js'; | ||
|
||
const NUMBER_OF_ROWS = 5000; | ||
|
||
benchmark(`dom/slot/light/create/5k`, () => { | ||
let slottingComponent; | ||
let rowsOfComponentWithSlot; | ||
let rowsOfSlottedContent; | ||
|
||
before(() => { | ||
slottingComponent = createElement('benchmark-slot-usage-component-light', { | ||
is: SlotUsage, | ||
}); | ||
const store = new Store(); | ||
|
||
rowsOfComponentWithSlot = store.buildData(NUMBER_OF_ROWS); | ||
rowsOfSlottedContent = store.buildData(NUMBER_OF_ROWS); | ||
return insertComponent(slottingComponent); | ||
}); | ||
|
||
run(() => { | ||
slottingComponent.componentContent = 'Parent component slotting content to child cmp'; | ||
slottingComponent.rowsOfSlottedContent = rowsOfSlottedContent; | ||
slottingComponent.titleOfComponentWithSlot = 'Component that receives a slot'; | ||
slottingComponent.rowsOfComponentWithSlot = rowsOfComponentWithSlot; | ||
}); | ||
|
||
after(() => { | ||
destroyComponent(slottingComponent); | ||
}); | ||
}); |
43 changes: 43 additions & 0 deletions
43
...marks__/engine-dom/benchmark-slot-light/light-slot-update-slotted-content-5k.benchmark.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* 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 { createElement } from '@lwc/engine-dom'; | ||
|
||
import SlotUsage from '@lwc/perf-benchmarks-components/dist/dom/benchmark/slotUsageComponentLight/slotUsageComponentLight.js'; | ||
import Store from '@lwc/perf-benchmarks-components/dist/dom/benchmark/store/store.js'; | ||
import { insertComponent, destroyComponent } from '../../../utils/utils.js'; | ||
|
||
const NUMBER_OF_ROWS = 5000; | ||
|
||
benchmark(`dom/slot/light/update-slotted-content/5k`, () => { | ||
let slottingComponent; | ||
let nextData; | ||
|
||
before(async () => { | ||
slottingComponent = createElement('benchmark-slot-usage-component-light', { | ||
is: SlotUsage, | ||
}); | ||
|
||
const store = new Store(); | ||
|
||
slottingComponent.componentContent = 'Parent component slotting content to child cmp'; | ||
slottingComponent.titleOfComponentWithSlot = 'Component that receives a slot'; | ||
slottingComponent.rowsOfSlottedContent = store.buildData(NUMBER_OF_ROWS); | ||
slottingComponent.rowsOfComponentWithSlot = store.buildData(NUMBER_OF_ROWS); | ||
|
||
nextData = store.buildData(NUMBER_OF_ROWS); | ||
|
||
await insertComponent(slottingComponent); | ||
}); | ||
|
||
run(() => { | ||
slottingComponent.rowsOfSlottedContent = nextData; | ||
}); | ||
|
||
after(() => { | ||
destroyComponent(slottingComponent); | ||
}); | ||
}); |
29 changes: 29 additions & 0 deletions
29
.../perf-benchmarks/src/__benchmarks__/ssr/slots/light-slot-create-container-5k.benchmark.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { renderComponent } from '@lwc/ssr-runtime'; | ||
import SlotUsage from '@lwc/perf-benchmarks-components/dist/ssr/benchmark/slotUsageComponentLight/slotUsageComponentLight.js'; | ||
import Store from '@lwc/perf-benchmarks-components/dist/ssr/benchmark/store/store.js'; | ||
|
||
const SSR_MODE = 'asyncYield'; | ||
const NUMBER_OF_ROWS = 5000; | ||
|
||
benchmark(`ssr/slot/light/create/5k`, () => { | ||
let store; | ||
let rowsOfComponentWithSlot; | ||
let rowsOfSlottedContent; | ||
|
||
before(() => { | ||
store = new Store(); | ||
rowsOfComponentWithSlot = store.buildData(NUMBER_OF_ROWS); | ||
rowsOfSlottedContent = store.buildData(NUMBER_OF_ROWS); | ||
}); | ||
|
||
run(() => { | ||
const props = { | ||
rows: store.data, | ||
componentContent: 'Parent component slotting content to child cmp', | ||
rowsOfSlottedContent: rowsOfSlottedContent, | ||
titleOfComponentWithSlot: 'Component that receives a slot', | ||
rowsOfComponentWithSlot: rowsOfComponentWithSlot, | ||
}; | ||
return renderComponent('benchmark-slot-usage-component-light', SlotUsage, props, SSR_MODE); | ||
}); | ||
}); |