File tree Expand file tree Collapse file tree 3 files changed +103
-0
lines changed
test/benchmarks/mdc/button Expand file tree Collapse file tree 3 files changed +103
-0
lines changed Original file line number Diff line number Diff line change 1+ load ("@npm_angular_dev_infra_private//benchmark/component_benchmark:component_benchmark.bzl" , "component_benchmark" )
2+
3+ # TODO(wagnermaciel): Update this target to provide indigo-pink in a way that doesn't require having to import it with
4+ # stylesUrls inside the components once `component_benchmark` supports asset injection.
5+
6+ component_benchmark (
7+ name = "benchmark" ,
8+ driver = ":button.perf-spec.ts" ,
9+ driver_deps = [
10+ "@npm//@angular/dev-infra-private" ,
11+ "@npm//protractor" ,
12+ "@npm//@types/jasmine" ,
13+ ],
14+ ng_deps = [
15+ "@npm//@angular/core" ,
16+ "@npm//@angular/platform-browser" ,
17+ "//src/material-experimental/mdc-button" ,
18+ ],
19+ ng_srcs = [":app.module.ts" ],
20+ prefix = "" ,
21+ styles = ["//src/material-experimental/mdc-theming:indigo_pink_prebuilt" ],
22+ )
Original file line number Diff line number Diff line change 1+ /**
2+ * @license
3+ * Copyright Google LLC All Rights Reserved.
4+ *
5+ * Use of this source code is governed by an MIT-style license that can be
6+ * found in the LICENSE file at https://angular.io/license
7+ */
8+
9+ import { Component , NgModule , ViewEncapsulation } from '@angular/core' ;
10+ import { BrowserModule } from '@angular/platform-browser' ;
11+ import { MatButtonModule } from '@angular/material-experimental/mdc-button' ;
12+
13+ /** component: mdc-raised-button */
14+
15+ @Component ( {
16+ selector : 'app-root' ,
17+ template : `
18+ <button id="show" (click)="show()">Show</button>
19+ <button id="hide" (click)="hide()">Hide</button>
20+ <button *ngIf="isVisible" mat-raised-button>Basic</button>
21+ ` ,
22+ encapsulation : ViewEncapsulation . None ,
23+ styleUrls : [ '//src/material-experimental/mdc-theming/prebuilt/indigo-pink.css' ] ,
24+ } )
25+ export class ButtonBenchmarkApp {
26+ isChecked = false ;
27+ isVisible = false ;
28+
29+ show ( ) { this . isVisible = true ; }
30+ hide ( ) { this . isVisible = false ; }
31+ }
32+
33+
34+ @NgModule ( {
35+ declarations : [ ButtonBenchmarkApp ] ,
36+ imports : [
37+ BrowserModule ,
38+ MatButtonModule ,
39+ ] ,
40+ providers : [ ] ,
41+ bootstrap : [ ButtonBenchmarkApp ] ,
42+ } )
43+ export class AppModule { }
Original file line number Diff line number Diff line change 1+ /**
2+ * @license
3+ * Copyright Google LLC All Rights Reserved.
4+ *
5+ * Use of this source code is governed by an MIT-style license that can be
6+ * found in the LICENSE file at https://angular.io/license
7+ */
8+
9+ import { $ , browser } from 'protractor' ;
10+ import { runBenchmark } from '@angular/dev-infra-private/benchmark/driver-utilities' ;
11+
12+ describe ( 'button performance benchmarks' , ( ) => {
13+ beforeAll ( ( ) => {
14+ browser . rootEl = '#root' ;
15+ } ) ;
16+
17+ it ( 'renders a basic raised button' , async ( ) => {
18+ await runBenchmark ( {
19+ id : 'button-render' ,
20+ url : '' ,
21+ ignoreBrowserSynchronization : true ,
22+ params : [ ] ,
23+ prepare : async ( ) => await $ ( '#hide' ) . click ( ) ,
24+ work : async ( ) => await $ ( '#show' ) . click ( ) ,
25+ } ) ;
26+ } ) ;
27+
28+ it ( 'clicks a basic raised button' , async ( ) => {
29+ await runBenchmark ( {
30+ id : 'button-click' ,
31+ url : '' ,
32+ ignoreBrowserSynchronization : true ,
33+ params : [ ] ,
34+ setup : async ( ) => await $ ( '#show' ) . click ( ) ,
35+ work : async ( ) => await $ ( '.mat-raised-button' ) . click ( ) ,
36+ } ) ;
37+ } ) ;
38+ } ) ;
You can’t perform that action at this time.
0 commit comments