File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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/button" ,
18+ ],
19+ ng_srcs = [":app.module.ts" ],
20+ prefix = "" ,
21+ styles = ["//src/material/prebuilt-themes:indigo-pink" ],
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/button' ;
12+
13+ @Component ( {
14+ selector : 'app-root' ,
15+ template : `
16+ <button id="show" (click)="show()">Show</button>
17+ <button id="hide" (click)="hide()">Hide</button>
18+
19+ <button *ngIf="isVisible" mat-raised-button>Basic</button>
20+ ` ,
21+ encapsulation : ViewEncapsulation . None ,
22+ styleUrls : [ '//src/material/core/theming/prebuilt/indigo-pink.css' ] ,
23+ } )
24+ export class ButtonBenchmarkApp {
25+ isChecked = false ;
26+ isVisible = false ;
27+
28+ show ( ) { this . isVisible = true ; }
29+ hide ( ) { this . isVisible = false ; }
30+ }
31+
32+
33+ @NgModule ( {
34+ declarations : [ ButtonBenchmarkApp ] ,
35+ imports : [
36+ BrowserModule ,
37+ MatButtonModule ,
38+ ] ,
39+ providers : [ ] ,
40+ bootstrap : [ ButtonBenchmarkApp ] ,
41+ } )
42+ 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+ } ) ;
Original file line number Diff line number Diff line change @@ -17,13 +17,11 @@ import {MatCheckboxModule} from '@angular/material/checkbox';
1717 <button id="hide" (click)="hide()">Hide</button>
1818 <button id="indeterminate" (click)="indeterminate()">Indeterminate</button>
1919
20- <ng-container *ngIf="isVisible">
21- <mat-checkbox
22- [checked]="isChecked"
23- [indeterminate]="isIndeterminate"
24- (change)="toggleIsChecked()">
25- Check me!</mat-checkbox>
26- </ng-container>
20+ <mat-checkbox *ngIf="isVisible"
21+ [checked]="isChecked"
22+ [indeterminate]="isIndeterminate"
23+ (change)="toggleIsChecked()">
24+ Check me!</mat-checkbox>
2725 ` ,
2826 encapsulation : ViewEncapsulation . None ,
2927 styleUrls : [ '//src/material/core/theming/prebuilt/indigo-pink.css' ] ,
@@ -47,6 +45,6 @@ export class CheckboxBenchmarkApp {
4745 MatCheckboxModule ,
4846 ] ,
4947 providers : [ ] ,
50- bootstrap : [ CheckboxBenchmarkApp ]
48+ bootstrap : [ CheckboxBenchmarkApp ] ,
5149} )
5250export class AppModule { }
You can’t perform that action at this time.
0 commit comments