-
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.
- Loading branch information
1 parent
5e28246
commit deabb6c
Showing
3 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
103 changes: 103 additions & 0 deletions
103
packages/perf-benchmarks-components/src/benchmark/expensiveGetter/expensiveGetter.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,103 @@ | ||
<template> | ||
<div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
<div>{bigPrimeNumber}</div> | ||
</div> | ||
</template> |
28 changes: 28 additions & 0 deletions
28
packages/perf-benchmarks-components/src/benchmark/expensiveGetter/expensiveGetter.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,28 @@ | ||
/* | ||
* 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'; | ||
|
||
const isPrime = (n) => { | ||
const limit = Math.sqrt(n); | ||
for (let i = 2; i <= limit; i++) { | ||
if (n % i === 0) return false; | ||
} | ||
return true; | ||
}; | ||
|
||
export default class ExpensiveGetter extends LightningElement { | ||
@api | ||
get bigPrimeNumber() { | ||
let prime = 0; | ||
for (let i = 0; i < 10000; i++) { | ||
if (isPrime(i)) { | ||
prime = i; | ||
} | ||
} | ||
return prime; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...-benchmarks/src/__benchmarks__/engine-dom/benchmark-general/expensive-getter.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,27 @@ | ||
/* | ||
* 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'; | ||
|
||
import ExpensiveGetter from 'perf-benchmarks-components/dist/dom/benchmark/expensiveGetter/expensiveGetter.js'; | ||
import { insertComponent, destroyComponent } from '../../../utils/utils.js'; | ||
|
||
benchmark(`benchmark-table/append/1k`, () => { | ||
let element; | ||
|
||
before(async () => { | ||
element = createElement('expensive-getter', { is: ExpensiveGetter }); | ||
}); | ||
|
||
run(async () => { | ||
await insertComponent(element); | ||
}); | ||
|
||
after(() => { | ||
destroyComponent(element); | ||
}); | ||
}); |