Skip to content

Commit

Permalink
test: add new benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson committed Jun 30, 2021
1 parent 5e28246 commit deabb6c
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 0 deletions.
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>
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;
}
}
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);
});
});

0 comments on commit deabb6c

Please sign in to comment.