Skip to content

Commit

Permalink
add perf testing with tensile
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdholt committed Feb 13, 2024
1 parent 6809b55 commit d961b60
Show file tree
Hide file tree
Showing 8 changed files with 632 additions and 43 deletions.
47 changes: 27 additions & 20 deletions packages/web-components/docs/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,29 @@ export const BadgeStyles: ElementStyles;
// @public (undocumented)
export const BadgeTemplate: ElementViewTemplate<Badge>;

// @public
export class BaseTabs extends FASTElement {
activeid: string;
// @internal (undocumented)
activeidChanged(oldValue: string, newValue: string): void;
activetab: HTMLElement;
adjust(adjustment: number): void;
// @internal (undocumented)
connectedCallback(): void;
orientation: TabsOrientation;
// @internal (undocumented)
orientationChanged(): void;
protected setTabs(): void;
// @internal (undocumented)
tabpanels: HTMLElement[];
// @internal (undocumented)
tabpanelsChanged(): void;
// @internal (undocumented)
tabs: HTMLElement[];
// @internal (undocumented)
tabsChanged(): void;
}

// @public (undocumented)
export const borderRadiusCircular = "--borderRadiusCircular";

Expand Down Expand Up @@ -2633,30 +2656,14 @@ export const TabPanelStyles: ElementStyles;
// @public (undocumented)
export const TabPanelTemplate: ElementViewTemplate<TabPanel, any>;

// @public
export class Tabs extends FASTElement {
activeid: string;
// @internal (undocumented)
// @public (undocumented)
export class Tabs extends BaseTabs {
// (undocumented)
activeidChanged(oldValue: string, newValue: string): void;
activetab: HTMLElement;
adjust(adjustment: number): void;
appearance?: TabsAppearance;
// @internal (undocumented)
connectedCallback(): void;
disabled?: boolean;
orientation: TabsOrientation;
// @internal (undocumented)
orientationChanged(): void;
// (undocumented)
protected setTabs: () => void;
size?: TabsSize;
// @internal (undocumented)
tabpanels: HTMLElement[];
// @internal (undocumented)
tabpanelsChanged(): void;
// @internal (undocumented)
tabs: HTMLElement[];
// @internal (undocumented)
// (undocumented)
tabsChanged(): void;
}

Expand Down
2 changes: 2 additions & 0 deletions packages/web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
"scripts": {
"tsc": "tsc",
"api-extractor": "api-extractor",
"benchmark": "tsc -p ./tsconfig.bench.json && npx tensile --file ./dist/esm/button/button.bench.js",
"compile": "node ./scripts/compile",
"clean": "node ./scripts/clean dist",
"generate-api": "api-extractor run --local",
Expand All @@ -197,6 +198,7 @@
"devDependencies": {
"@microsoft/api-extractor": "7.31.2",
"@storybook/html": "6.5.15",
"@tensile-perf/web-components": "~0.1.12",
"rimraf": "^3.0.2",
"typescript": "4.7.4"
},
Expand Down
10 changes: 10 additions & 0 deletions packages/web-components/src/button/button.bench.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import './button.definition.js';

const itemRenderer = () => {
const btn = document.createElement('fluent-button');
btn.appendChild(document.createTextNode('Fluent button'));
return btn;
};

export default itemRenderer;
export { tests } from '../utils/benchmark-wrapper.js';
20 changes: 20 additions & 0 deletions packages/web-components/src/utils/benchmark-wrapper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { tests } from '@tensile-perf/web-components';
import { webLightTheme } from '@fluentui/tokens';
import { setTheme } from '@fluentui/web-components';

const testWrapper = (test: any, args: any) => {
setTheme(webLightTheme);
return test(args);
};

const wrappedTests = {};

for (const testName of Object.keys(tests)) {
const test = tests[testName];

wrappedTests[testName] = (args: any) => {
return testWrapper(test, args);
};
}

export { wrappedTests as tests };
9 changes: 9 additions & 0 deletions packages/web-components/tsconfig.bench.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"moduleResolution": "Node16",
"noImplicitAny": false,
"outDir": "dist/esm"
},
"include": ["./src/**/*.bench.ts", "./src/utils/benchmark-wrapper.ts"]
}
3 changes: 3 additions & 0 deletions packages/web-components/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
{
"path": "./tsconfig.spec.json"
},
{
"path": "./tsconfig.bench.json"
},
{
"path": "./.storybook/tsconfig.json"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/web-components/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
"types": []
},
"include": ["src"],
"exclude": ["**/*.stories.*", "**/*.test.*", "**/*.spec.*"]
"exclude": ["**/*.stories.*", "**/*.test.*", "**/*.spec.*", "**/*.bench.*", "src/utils/benchmark-wrapper.ts"]
}
Loading

0 comments on commit d961b60

Please sign in to comment.