Skip to content

Commit

Permalink
add default operations, enable user to add and run custom operations …
Browse files Browse the repository at this point in the history
…5841 (#5921)

* added update 10th test, moved all template generate logic to template.js, now  just need to add one .ts file to run benchmark

* add default tests

* enable operations argument to run specified operations

Co-authored-by: Wendy <[email protected]>
  • Loading branch information
prudepixie and Wendy authored Apr 29, 2022
1 parent 75c4f80 commit 0e9f246
Show file tree
Hide file tree
Showing 18 changed files with 658 additions and 295 deletions.
4 changes: 4 additions & 0 deletions packages/web-components/fast-benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,7 @@ example:
`yarn run benchmark --library=fast-element --benchmark=binding --versions=1.9.0 local`
`yarn run benchmark --library=fast-element --benchmark=binding --versions=1.9.0 master`
`yarn run benchmark --library=fast-foundation --benchmark=form-associated -v 2.34.0 2.42.1`

`yarn run benchmark --library=fast-element --benchmark=test --versions=1.9.0 local`

- this should run all default test suite
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
repeat,
} from "@microsoft/fast-element";

import { _random, adjectives, colours, nouns } from "../../../utils/constants.js";
import { _random, adjectives, colours, nouns } from "../../../utils/index.js";
import runBenchmark from "./shared.js";

const itemCount = 250;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
oneTime,
repeat,
} from "@microsoft/fast-element";
import { _random, adjectives, colours, nouns } from "../../../utils/constants.js";
import { _random, adjectives, colours, nouns } from "../../../utils/index.js";
import runBenchmark from "./shared.js";

const itemCount = 250;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
declare global {
interface Window {
usedJSHeapSize: any;
gc: any;
}
interface Performance {
memory: any;
}
}

function measureMemory() {
if (window && performance && performance.memory) {
// Report results in MBs\
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import {
attr,
css,
customElement,
FASTElement,
html,
observable,
repeat,
} from "@microsoft/fast-element";
import { data, RandomItem } from "../../../utils/index.js";

@customElement({
name: "x-item",
template: html<XItem>`
<div @click="${x => x.onClick}" class="item">
${x => x.value}
</div>
`,
styles: css`
.item {
display: flex;
}
`,
})
class XItem extends FASTElement {
@attr value: string | undefined;
onClick(e: MouseEvent) {
console.log(e.type);
}
}

@customElement({
name: "x-app",
template: html<XApp>`
<div>
${repeat(
x => x.items,
html`
<x-item :value="${x => x.label}"></x-item>
`
)}
</div>
`,
})
class XApp extends FASTElement {
@observable items: RandomItem[] = data;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {
attr,
bind,
css,
customElement,
FASTElement,
html,
oneTime,
repeat,
} from "@microsoft/fast-element";
import { data, RandomItem } from "../../../utils/index.js";

const xItemTemplate = html<XItem>`
<div @click="${x => x.onClick}" class="item">
${x => x.value}
</div>
`;

const styles = css`
.item {
display: flex;
}
`;
@customElement({
name: "x-item",
template: xItemTemplate,
styles,
})
class XItem extends FASTElement {
@attr value: string | undefined;

onClick(e: MouseEvent) {
console.log(e.type);
}
}

const xAppTemplate = html<XApp>`
<div id="test-container">
${repeat(
x => x.items,
html<RandomItem>`
<x-item
:value="${bind((x: { label: string }) => x.label, oneTime)}"
></x-item>
`
)}
</div>
`;
@customElement({
name: "x-app",
template: xAppTemplate,
})
class XApp extends FASTElement {
items: RandomItem[] = data;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
repeat,
} from "@microsoft/fast-element";
import { FormAssociated, FoundationElement } from "@microsoft/fast-foundation";
import { _random, adjectives, colours, nouns } from "../../../utils/constants.js";
import { _random, adjectives, colours, nouns } from "../../../utils/index.js";

const itemCount = 250;
let id = 0;
Expand Down
1 change: 1 addition & 0 deletions packages/web-components/fast-benchmarks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "fast-benchmarks",
"version": "1.0.0",
"description": "",
"type": "module",
"scripts": {
"build": "tsc && tsc --build",
"benchmark": "node scripts/index.js",
Expand Down
Loading

0 comments on commit 0e9f246

Please sign in to comment.