Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions test/benchmarks/mdc/button/button.perf-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ describe('button performance benchmarks', () => {
ignoreBrowserSynchronization: true,
params: [],
setup: async () => await $('#show').click(),
<<<<<<< HEAD
<<<<<<< HEAD
work: async () => await $('.mat-mdc-raised-button').click(),
=======
work: async () => await $('.mat-raised-button').click(),
>>>>>>> f1ae4d955... test(mdc-button): add performance tests for mdc-button
=======
work: async () => await $('.mat-mdc-raised-button').click(),
>>>>>>> 63f2747fc... fixup! test(mdc-button): add performance tests for mdc-button
});
});
});
23 changes: 23 additions & 0 deletions test/benchmarks/mdc/form-field/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
load("@npm_angular_dev_infra_private//benchmark/component_benchmark:component_benchmark.bzl", "component_benchmark")

# TODO(wagnermaciel): Update this target to provide indigo-pink in a way that doesn't require having to import it with
# stylesUrls inside the components once `component_benchmark` supports asset injection.

component_benchmark(
name = "benchmark",
driver = ":form-field.perf-spec.ts",
driver_deps = [
"@npm//@angular/dev-infra-private",
"@npm//protractor",
"@npm//@types/jasmine",
],
ng_deps = [
"@npm//@angular/core",
"@npm//@angular/platform-browser",
"//src/material-experimental/mdc-form-field",
"//src/material-experimental/mdc-input",
],
ng_srcs = [":app.module.ts"],
prefix = "",
styles = ["//src/material-experimental/mdc-theming:indigo_pink_prebuilt"],
)
60 changes: 60 additions & 0 deletions test/benchmarks/mdc/form-field/app.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

import {Component, NgModule, ViewEncapsulation} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {MatFormFieldModule} from '@angular/material-experimental/mdc-form-field';
import {MatInputModule} from '@angular/material-experimental/mdc-input';

/** component: mdc-form-field */

@Component({
selector: 'app-root',
template: `
<button id="show-input" (click)="showInput()">Show Input</button>
<button id="show-textarea" (click)="showTextarea()">Show Textarea</button>

<button id="hide" (click)="hide()">Hide</button>

<mat-form-field appearance="fill" *ngIf="isInputVisible">
<mat-label>Input</mat-label>
<input matInput>
</mat-form-field>

<mat-form-field appearance="fill" *ngIf="isTextareaVisible">
<mat-label>Textarea</mat-label>
<textarea matInput></textarea>
</mat-form-field>
`,
encapsulation: ViewEncapsulation.None,
styleUrls: ['//src/material-experimental/mdc-theming/prebuilt/indigo-pink.css'],
})
export class FormFieldBenchmarkApp {
isInputVisible = false;
isTextareaVisible = false;

showInput() { this.isInputVisible = true; }
showTextarea() { this.isTextareaVisible = true; }

hide() {
this.isInputVisible = false;
this.isTextareaVisible = false;
}
}


@NgModule({
declarations: [FormFieldBenchmarkApp],
imports: [
BrowserModule,
MatFormFieldModule,
MatInputModule,
],
bootstrap: [FormFieldBenchmarkApp],
})
export class AppModule {}
35 changes: 35 additions & 0 deletions test/benchmarks/mdc/form-field/form-field.perf-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

import {$, browser} from 'protractor';
import {runBenchmark} from '@angular/dev-infra-private/benchmark/driver-utilities';

function runFormFieldRenderBenchmark(testId: string, showBtnId: string) {
return runBenchmark({
id: testId,
url: '',
ignoreBrowserSynchronization: true,
params: [],
prepare: async () => await $('#hide').click(),
work: async () => await $(showBtnId).click()
});
}

describe('form field performance benchmarks', () => {
beforeAll(() => {
browser.rootEl = '#root';
});

it('renders an input in a form field', async() => {
await runFormFieldRenderBenchmark('input-form-field-render', '#show-input');
});

it('renders an textarea in a form field', async() => {
await runFormFieldRenderBenchmark('textarea-form-field-render', '#show-textarea');
});
});